Reputation: 2043
I was converting some VB code to C#. I have these 2 statements with me currently written in VB
Dim LineSeparator As Char = Convert.ToChar(10)
Dim DataSeparator As Char = Convert.ToChar(";")
I checked the value in Watch
Window and could see something like this
Name Value Type
LineSeparator ""c Char
DataSeparator ";"c Char
I wrote similar C#
statements
char LineSeparator = Convert.ToChar(10);
char DataSeparator = Convert.ToChar(";");
but the watch shows a different result. Something Like this
LineSeparator 10 '\n' char
DataSeparator 59 ';' char
What Wrong I am doing here? Do i need to put Single Quotes around the parameters?
Upvotes: 1
Views: 161
Reputation: 216293
No the results are correct, it is only a difference in the way used by the debug window to show certain constant values between C# and VB.NET
The character with code 10 is the LineFeed character (a non printable one) and the debugger in VB don't show anything between the double quotes (but the character is there). In the C# debugger these non printable characters are represented by the escape prefix (\) follwed by one letter defined for some of them.
For the semicolon instead, the problem is that VB.NET use the same quoting both for a single character and for strings. Thus they added the letter "c" to show that this is a char value and not a string. Instead C# uses the single quote around character constants
Upvotes: 1