Friday, 16 October 2015

Lower case, Upper case and Substring in string in C#

using System;
class Program
{
    static void Main()
    {
        string str = "inDia Is mY CoUnTrY";
        Console.WriteLine("Displaying same input string\n");
        Console.WriteLine(str);
        Console.WriteLine("\nCalling ToLower instance method which creates new copy in lower case\n");
        Console.WriteLine(str.ToLower());
        Console.WriteLine("\nCalling ToUpper instance method which creates new copy in Upper case\n");
        Console.WriteLine(str.ToUpper());
        Console.WriteLine("\nCalling Substring instance method to start from 5th index and retrieve rest of string");
        Console.WriteLine(str.Substring(5));
        Console.WriteLine("\nCalling Substring instance method to start from 0 index to 5 length");
        Console.WriteLine(str.Substring(0, 5));
    }
}

No comments:

Post a Comment