Compares to another Char

Syntax:


public int CompareTo(char value)

ParametersTypeMeaning
valueSystem.CharA Char object to compare.

Return ValueDescription
Less than zeroThis instance precedes value.
ZeroThis instance has the same position in the sort order as value.
Greater than zeroThis instance follows value.

using System;

class Sample 
{
    public static void Main() 
    {
       char ch='A';
       
       int result = ch.CompareTo('B');
    
       Console.WriteLine(result);
    }
}

The output:


-1
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.