Getting Alphabets from Number using C#

In this blog we are going to see, How to Get Alphabets from the Number using C#

 

Declare string for alphabet

string strAlpha = "";

 

Loop through the ASCII characters 65 to 90

for (int i = 65; i <= 90; i++) //

 

Convert the int to a char to get the actual character behind the ASCII code

strAlpha += ((char)i).ToString() + " ";

 

 

Displaying alphabets

Response.Write(strAlpha);

 

Code Snippet:

 

public void GetAlphabets()

        {

            //Declare string for alphabet

            string strAlpha = "";

 

            //Loop through the ASCII characters 65 to 90

            for (int i = 65; i <= 90; i++) //

            {

                // Convert the int to a char to get the actual character behind the ASCII code

                strAlpha += ((char)i).ToString() + " ";

            }

 

            //Displaying alphabets

            Response.Write(strAlpha);

 

        }

 

 

OUTPUT:

 

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