Compare char value
In this chapter you will learn:
Compares to another Char
We can use the CompareTo(char value) method to compare two char values: The CompareTo(char value) returns the following values:
Return Value | Description |
---|---|
Less than zero | This instance precedes value. |
Zero | This instance has the same position in the sort order as value. |
Greater than zero | This instance follows value. |
using System;//from j av a 2 s .c o m
class Sample
{
public static void Main()
{
char ch='A';
int result = ch.CompareTo('B');
Console.WriteLine(result);
}
}
The output:
Next chapter...
What you will learn in the next chapter: