I declared an extension method as follows
namespace ExtensionMethods
{
public static class MyExtensions
{
const string Nil = "$$$NIL$$$";
public static bool IsEmptyNullOrNil(this string str)
{
if (string.IsNullOrEmpty(str) || str == Nil)
{
return true;
}
return false;
}
}
}
And in my controller class, I included the namespace. But the program does not compile. But I could use the function as normal static method.
Any help will be appreciated.
CodePudding user response:
Your extension method can be accessed in the following ways
if (!employeeFilter.Name.IsEmptyNullOrNil())
OR
if (!MyExtensions.IsEmptyNullOrNil(employeeFilter.Name))