CSharp - Write program to Change text case


The user will enter two names.

You will evaluate whether they are the same or different, disregarding the difference between lowercase and uppercase.


You need to convert both pieces of text to lowercase prior to doing the comparison.

You can use the ToLower method call for that purpose.


using System;
class Program//from   w  w  w  . j  a  va  2s  .c  o  m
    static void Main(string[] args)
        // Inputs 
        Console.Write("Enter a name: ");
        string name1 = Console.ReadLine();

        Console.Write("Enter another name: ");
        string name2 = Console.ReadLine();

        // Converting to small letters 
        string name1inSmall = name1.ToLower();
        string name2inSmall = name2.ToLower();

        // Evaluating 
        if (name1inSmall == name2inSmall)
            Console.WriteLine("You have entered the same names");
            Console.WriteLine("You have entered different names");