I am not able to figure out the simple compile error I am getting on Regex.Match
method.
The error says
Cannot access non-static method 'IsMatch' in static context
The error text is confusing in itself because the method I am calling is the static method of the Regex
class while the error says that I cannot access non-static
method in statc context.
My context is also not static
because the method in which I have calling Regex.IsMatch
function is a non-static method, even the class is also non static.
The error is confusing!
It works when I replace the call with the Regex class' instance call like this
new Regex(@"/^(?:2[89]|[3-9]\d)\d{6,}$/").IsMatch(@"/^(?:2[89]|[3-9]\d)\d{6,}$/")
But I am totally confused of why can't I call the static method of the class!