Give a Character Type Example ?
Answer:
Consider an example in which we declare one variable of type char, initialize it with value 'a', then 'b', then 'A' and print the Unicode values of these letters to the console:
// Declare a variable
char ch = 'a';
// Print the results on the console
Console.WriteLine( "The code of '" + ch + "' is: " + (int)ch); ch = 'b';
Console.WriteLine( "The code of '" + ch + "' is: " + (int)ch); ch = 'A';
Console.WriteLine( "The code of '" + ch + "' is: " + (int)ch);
// Console output:
// The code of 'a' is: 97
// The code of 'b' is: 98
// The code of 'A' is: 65
No comments:
Post a Comment