Compare alphanumeric strings for greater/less than equality C#

I have some alphanumeric strings to compare. I need to know if A1234 is before B5678 when sorted alphanumerically. I also want to ignore the case of the alphabetic characters.

int comparison = String.Compare(A1234, B5678, comparisonType: StringComparison.OrdinalIgnoreCase);

The integer returned will be -1 if lower in order, 0 if equal and 1 if greater.

Leave a Reply