Q:
When i convert from string to character through the following line of code.
grp.EntireClass = char.Parse(record[3]);
I get the following value:: 49'1'
-
Firstly why the ascii appear as a
part of the value? -
Secondly how to get only the
'1'
part?
I suspect you don’t actually get “49’1′” – that’s probably just how the debugger’s showing it.
A simpler way though is:
This is equivalent to:
I split it out in the first version just for clarity.
You may well want to check that text is not:
In the first two cases the above code will throw an exception; in the third case it would just ignore everything after the first character.