[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


Static member cannot be accessed with an instance reference; qualify it with a type name instead

Posted on 2006-07-11
Medium Priority
Last Modified: 2008-01-09

I've got this error: Static member 'System.Text.RegularExpressions.Regex.IsMatch(string, string)' cannot be accessed with an instance reference; qualify it with a type name instead

I really can't find what's going wrong. Another solution on EE gives an answer: use classname, but that's what I do. (const.InvalidAlbumPattern). Still the error occurs...

below a code snippet:
public sealed class FileManager
        private class Consts
        { ...
                        public const string InvalidAlbumPattern = "[\\\\/:*?\"<>|]";

        public static bool IsValidAlbumName(string name)
            Regex reg;
            if (reg.IsMatch(name, Consts.InvalidAlbumPattern)) <<<<<--------- HERE'S THE ERROR
                return false;

Thanks in advance
Question by:kGenius
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 48

Accepted Solution

AlexFM earned 2000 total points
ID: 17083565
if (Regex.IsMatch(name, Consts.InvalidAlbumPattern))

Expert Comment

ID: 17083795
>> use classname, but that's what I do.
The Error occured because of *IsMatch* method NOT *Consts.InvalidAlbumPattern* ..
So As *AlexFM* posted .. Use The class name *Regex* (where the *IsMethod* method is implemented ..)
Because It Is A Static Member(Method) ..

regards, Ahmad;
LVL 48

Expert Comment

ID: 17083852
What is the point to post duplicated answer?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 17083929
>>use classname, but that's what I do.<<
It Is Not A Duplicated Answer .. I've just provided my post with some explanation about the error ..
As He Mentioned , He thought the problem because *InvalidAlbumPattern* ..

Sorry If I made you upset ..

* kGenius * please don't consider my post as an answer ..

thanx, Ahmad;
LVL 11

Expert Comment

ID: 17085027
there is nothig bad in giving some more explanations alex. ;)

Author Comment

ID: 17088101
Well DrAske thanks for the explanation. But I've found the solution 5 minutes after posting the question... I've searched for this for hours. Then I get this genius idea (hmm) to change the InvalidAlbumPattern to a hard coded string("...").
And still error occurs. Then my light burned ! It must gave been the reg.IsMatch -> RegEx.IsMatch.
Nevertheless AlexFM and DrAske both thanks for the help.
And AlexFM gets the points as he came up with the answer...
DrAske you're too good, giving explanation without waiting for points. That's what the world makes so good, AlexFM. Helping eachother without waiting for a reward !

genius is 1% inspiration and 99% perspiration

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question