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.
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:
All other versions (including Silverlight) are listed as:
If you are seeing otherwise (please treble-check), it could be a framework error… but I’m cautiously expecting a simpler explanation.