I can’t seem to get the following extension method to be found in another class in the same namespace (MyProject.Util).
using System.Collections.Specialized;
namespace MyProject.Util
{
public static class Extensions
{
public static string Get(
this NameValueCollection me,
string key,
string def
)
{
return me[key] ?? def;
}
}
}
As you can see it’s basically another version of foo[bar] ?? baz, but I still don’t understand why VS2008 fails to compile telling me that no version of Get takes two arguments.
Any ideas?
Are you importing your namespace (with
using MyProject.Util) in the file where you’re using the method? The error message might not be obvious because your extension method has the same name as an existing method.