Search code examples
c#public-method

c# static public method


Within a class called Security, there is a method:

    public static bool HasAccess(string UserId, string ModuleID)

How do I call this method and so it can return a bool result?

I tried the followoing but was not successful:

    Security security = new Security();
    bool result = security.HasAccess("JKolk","Accounting");

Solution

  • You just use the class name. No need to create an instance.

    Security.HasAccess( ... )