R
Richard
Can anyone help a VB programmer understand the following C# code snippet
please? This is excerpted from a base conversion function that converts s (a
string representing a number in any base 2 to 36) into a string representing
the number in another base.
if (s >= 'A' && s <= 'Z') { fs[k++] = 10 + (int)(s - 'A'); }
si is simply a character in a string passed to the function.
fs, according to the author, is an "array of integer digits representing the
number in base:from".
What I don't understand is .... (int) (s - 'A') , since both s and A
are characters.
If, say, s evaluates to 'F', then how does C# treat (int) ('F' - 'A')?
Does it simply convert the two characters into their ASCII numbers, thereby
evaluating it to 5?
TIA
please? This is excerpted from a base conversion function that converts s (a
string representing a number in any base 2 to 36) into a string representing
the number in another base.
if (s >= 'A' && s <= 'Z') { fs[k++] = 10 + (int)(s - 'A'); }
si is simply a character in a string passed to the function.
fs, according to the author, is an "array of integer digits representing the
number in base:from".
What I don't understand is .... (int) (s - 'A') , since both s and A
are characters.
If, say, s evaluates to 'F', then how does C# treat (int) ('F' - 'A')?
Does it simply convert the two characters into their ASCII numbers, thereby
evaluating it to 5?
TIA