Convert string from lower case to upper case in C#

In this code snippet we will see how to convert a string from lower case to upper case.


public static String ConvertToUpperCase(String input)
{
    String output = "";
    for (int i = 0; i < input.Length; i++)
    {
        if (input[i] >= 'a' && input[i] <= 'z')
        {
            output += (char)(input[i] - 'a' + 'A');
        }
        else
            output += input[i];
    }
    return output;
}

private void ConvertButton_Click(object sender, EventArgs e)
{
    textBox2.Text = ConvertToUpperCase(textBox1.Text);
}

Check out this video to understand more:


Reference:

convert-string-from-lowercase-to-uppercase-without-inbuilt-function
Convert string from lower case to upper case in C# Convert string from lower case to upper case in C# Reviewed by Bloggeur DZ on 12:03 Rating: 5

Aucun commentaire:

Fourni par Blogger.