Change string case

We can use ToUpper and ToLower to change the string case.


using System;

class Sample
{
    public static void Main()
    {
        string s = "java2s.com";

        Console.WriteLine(s.ToUpper());
        Console.WriteLine(s.ToLower());

    }
}

The output:


JAVA2S.COM
java2s.com

ToUpper and ToLower methods do the conversion based on user's locale.

To ignore the user's locale and do the conversion based on English locale we can use the ToUpperInvariant and ToLowerInvariant.

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.