C# extension method doesn't seem to exist

Posted by blahblah on Stack Overflow See other posts from Stack Overflow or by blahblah
Published on 2010-04-20T12:07:48Z Indexed on 2010/04/20 12:23 UTC
Read the original article Hit count: 301

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about extension-methods