Compare String - CSharp System

CSharp examples for System:String Compare

Description

Compare String

Demo Code


using System.Text;
using System.Collections.Generic;
using System;//from   www . j  a  v  a 2  s  .co m

public class Main{
        static int CompareString(string strA, string strB)
        {
            if (strA != null && strB != null)
            {
                if (strA.Length < strB.Length)
                {
                    return -1;
                }
                else if (strA.Length > strB.Length)
                {
                    return 1;
                }
            }
            return String.Compare(strA, strB, StringComparison.OrdinalIgnoreCase);
        }
}

Related Tutorials