Can't Access My Extension Method

Looking for a way to check if an string contains in another ignoring upper/lower case, I found it:

Works fine. Then, I tried put it to my StringExtensions namespace.

namespace StringExtensions
{

    public static class StringExtensionsClass
    {
        //... 

        public static bool Contains(this string target, string toCheck, StringComparison comp)
        {
            return target.IndexOf(toCheck, comp) >= 0;
        }
    }
}

and then:

using StringExtensions;

...

if (".. a".Contains("A", StringComparison.OrdinalIgnoreCase))

but I get the following error:

No overload for method 'Contains' takes '2' arguments

How do I fix it?

Answers


When you want to use your extension, add this using statement:

using StringExtensions;

Because of the way Extension methods are declared, visual studio won't find them by itself, and the regular Contains method takes one argument, hence your exception.


Need Your Help

How can I create URLs that only include the query string?

apache .htaccess url-rewriting

I want to use URL rewriting in apache web server to have these types of URLs:

how to send multiple html tablerow values into a PHP file

php

I'm new to the php environment and just need to know about from submission. Given below is my html table containing multiple rows.(This table is generated by PHP ECHO statements inside the server)....

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.