Saturday, August 7, 2010

Characters

Characters


In the English alphabet, a character is one of the following symbols: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, and Z. Besides these readable characters, the following symbols are called digits and they are used to represent numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. In addition, some symbols on the (US QWERTY) keyboard are also called characters or symbols. They are ` ~ ! @ # $ % ^ & * ( ) - _ = + [ { ] } \ | ; : ' < ? . / , > "

Besides the English language, other languages use other or additional characters that represent verbal or written expressions.

C# recognizes that everything that can be displayed as a symbol is called a character. To declare a variable whose value would be a character, you can use the var keyword and initialize the variable with a character in single-quotes. Here is an example:

using System;

class Exercise
{
static void Main()
{
var Gender = 'F';

Console.Write("Student Gender: ");
Console.WriteLine(Gender);
}
}

Alternatively, you can use the char keyword. Here is an example:

using System;

class Exercise
{
static void Main()
{
char Gender = 'M';

Console.Write("Student Gender: ");
Console.WriteLine(Gender);
}
}

This would produce:

Student Gender: M

No comments:

Post a Comment