The reason I am asking is because I wrote an extension method to use in Silverlight only to find out that feature magically started working for silver light.
Example
string sentence = "I am a sentence that has some words";
sentence.Contains("N"); //would return false, silverlight true
sentence.Contains("n"); //would return true, silverlight true
Why is there a special System dll in the framework for Silverlight that does the comparsion as case insenstive?
I have run into this for tons of methods, it's kind of annoying that they either act different or are just missing in general.
The reason I am asking is because I wrote an extension method to use in Silverlight only to find out that feature magically started working for silver light.
There is a public bool string.Contains(string)
method for all versions of .NET from 2.0 onwards (2.0, 3.0, 3.5, 4.0, SL 3/4 WP 7.0/7.1).
It is interesting to note that the SL version is only listed from SL 3 / 4 - is it possible you updated from a 2.0 solution? That could then account for it.
Otherwise, a defined method always takes precedence over an extension method, so your extension method should never be called (we can exclude .NET 1.1 since the C# 1.2 compiler does not include extension methods).
For .NET 2.0 MSDN documents this as:
This method performs a word (case-sensitive and culture-sensitive) search using the current culture. The search begins at the first character position of this string and continues through the last character position.
All other versions (including Silverlight) are listed as:
This method performs an ordinal (case-sensitive and culture-insensitive) comparison. The search begins at the first character position of this string and continues through the last character position.
If you are seeing otherwise (please treble-check), it could be a framework error... but I'm cautiously expecting a simpler explanation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With