Also is there any character to ASCII code and ASCII code to character
built-in function in C#?
One of the things that programmers coming from Basic language variant to
a C language variant have trouble with is that Basic imposes a completely
unnecessary distinction between numbers & characters, which C (and C++ and
C#) does not. So, the following code will print " A, 66":
public class MyClass
{
public static void Main()
{
Char c =(Char) 65;
int i = 'B';
Console.WriteLine("{0}, {1}", c, i);
}
}
Note that the cast it required to convert 65 to a character, but not to
convert 'B' into an int.
I am wondering how can I representation some of the special characters in
C#?
(for example, we use vbKeyTab for Tab and vbCrLf for line feed in VB)
So, with the above in mind, you can create Tab as a character simply by:
char csKeyTab = (char) 9;
However, you'll probably want them as string (and for vbCrLf, it would
have to be), inwhich case you can use the predefined "escape codes":
string csCrLf = "\r\n";
string csKeyTab = "\t";
But say you want a string containing a special character which doesn't
have a predefined code? This can be done also, but you'll have to translate
the ASCII code into Hexadecimal.
string csABC = "\x41\x42\x43"; // "ABC" "A" = ASCII 65 (dec) = 41
(hex)
--
Truth,
James Curran
Home:
www.noveltheory.com Work:
www.njtheater.com
Blog:
www.honestillusion.com Day Job:
www.partsearch.com
(note new day job!)