1- Display characters from a to z using loop in CSharp Console Application.
2- Display characters from A to Z using loop in CSharp Console Application.
1- In this program, the for loop is used to display the English alphabets in lowercase.
1 2 3 4 5 6 7 8 9 10 11 12 | static void Main(string[] args) { char karakter; for (karakter = 'a'; karakter <= 'z'; karakter++) { //Console.Write(karakter + " "); Console.Write("{0} ", karakter); } Console.ReadKey(); } |
Another way to print lowercase case alphabets
1 2 3 4 5 6 7 | for (int i = 0; i < 26; i++) { Console.Write(Convert.ToChar(i + (int)'a') + " "); } Console.ReadKey(); |
When you run the program, the output will be:
2- In this program, the for loop is used to display the English alphabets in uppercase.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | static void Main(string[] args) { char karakter; for (karakter = 'A'; karakter <= 'Z'; karakter++) { //Console.Write(karakter + " "); Console.Write("{0} ", karakter); } Console.ReadKey(); } |
Another way to print uppercase case alphabets
1 2 3 4 5 6 7 | for (int i = 0; i < 26; i++) { Console.Write(Convert.ToChar(i + (int)'A') + " "); } Console.ReadKey(); |
When you run the program, the output will be :