[Mono-list] Bug in String.IndexOf ?

Pedro Castro noup at users.sourceforge.net
Fri Nov 10 21:07:31 EST 2006


Running String.IndexOf with the StringComparison.Ordinal option
doesn't seem to produce correct results. However, using
CompareInfo.IndexOf does work. Test:

#############################################
using System;
using System.Globalization;

public class Test {

public static void Main () {
    string text = "testing123456";
    string text2 = "123";
    System.Console.WriteLine(text.IndexOf(text2, StringComparison.Ordinal));
    CompareInfo compare = CultureInfo.InvariantCulture.CompareInfo;
    System.Console.WriteLine(compare.IndexOf(text, text2,
CompareOptions.Ordinal));

}

}
#############################################

The output:
-1
7

-- 
Pedro Castro
http://mega.ist.utl.pt/~prmc


More information about the Mono-list mailing list