Saturday, March 1, 2014

Example of String.Compare() in C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StringCompare
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = "Hello World";
            string b = "Hello Friends";

            if(String.Compare(a,b)==0)
            {
                Console.WriteLine(a+" and "+b+" are equal");
            }
            else
            {
                Console.WriteLine(a+" and "+b+" are not equal");
            }
            Console.ReadLine();
        }
    }
}

Output:

No comments:

Post a Comment