B
btb900
Guest
so I have this :
int ConvertIntoNumber(char c)
{
int tempNumber = 0;
char[] tempC = new char[1];
tempC[0] = c;
string temp = new string(tempC);
switch(c)
{
case 'A':
tempNumber = 10;
break;
case 'B':
tempNumber = 11;
break;
case 'C':
tempNumber = 12;
break;
case 'D':
tempNumber = 13;
break;
case 'E':
tempNumber = 14;
break;
case 'F':
tempNumber = 15;
break;
default:
{
tempNumber = int.Parse(temp);
break;
}
}
return tempNumber;
}
and that works, just wanted to know if there is a cleaner way of doing this? just seems weird that I have to convert it in to a string 1st.
Continue reading...
int ConvertIntoNumber(char c)
{
int tempNumber = 0;
char[] tempC = new char[1];
tempC[0] = c;
string temp = new string(tempC);
switch(c)
{
case 'A':
tempNumber = 10;
break;
case 'B':
tempNumber = 11;
break;
case 'C':
tempNumber = 12;
break;
case 'D':
tempNumber = 13;
break;
case 'E':
tempNumber = 14;
break;
case 'F':
tempNumber = 15;
break;
default:
{
tempNumber = int.Parse(temp);
break;
}
}
return tempNumber;
}
and that works, just wanted to know if there is a cleaner way of doing this? just seems weird that I have to convert it in to a string 1st.
Continue reading...