I'm trying to compare string values:
using System;
public class Test
{
public static void Main()
{
int cmpValue = String.Compare("N-1.2.0.10", "N-1.2.0.8", StringComparison.InvariantCultureIgnoreCase);
if(cmpValue > 0)
Console.WriteLine("greater");
cmpValue = String.Compare("N-1.2.0.10", "N-1.2.1.10", StringComparison.InvariantCultureIgnoreCase);
if(cmpValue < 0)
Console.WriteLine("lesser");
cmpValue = String.Compare("N-1.2.0.10", "N-1.2.0.10", StringComparison.InvariantCultureIgnoreCase);
if(cmpValue == 0)
Console.WriteLine("equal");
}
}
lesser
equal
For some reason, the greater
case doesn't print. Why isn't "N-1.2.0.10"
considered greater than "N-1.2.0.8"
?