Question: I have a bunch of enumerations that represent permissions for various parts of the application.

```
public enum PermissionGroup1 
{
    CanDo11,
    CanDo12,
    CanDo13,
}

public enum PermissionGroup2 
{
    CanDo21,
    CanDo22,
    CanDo23,
}

public enum PermissionGroup3 
{
    CanDo31,
    CanDo32,
    CanDo33,
}

```

For a given user, I have a collection of all of the user's permissions, and then to check permissions I have a method like:

```
public Boolean CheckXXXAccess(int ModuleID, PermissionGroupX permission)
    {
        bool hasAccess = false;

        if (!m_Permissions.ContainsKey(ModuleID))
        {
            hasAccess = false;
        }
        else
        {
            hasAccess = (permission == (ModulePermissions[ModuleID].PermissionGroupX & permission));
        }

        return hasAccess;            
    }

```

So to explain it further, the database contains a ModuleID (there is a PermissionGroup enumeration for a given module type), and then I have a method like CheckXXXAccess for each module type.

**How can I use generics to make a single method instead of repeating it?**

Answer: 
I have implemented it this way.

Say `Perms` is your `ModulePermissions[ModuleID]` object's class. Then you could delegate checking access to it like this:

```
public bool CheckAccess<T>(int moduleId, T perm) {
    if(!ModulePermissions.ContainsKey(moduleId)) return false;
    return ModulePermissions[moduleId].HasPermission(perm);
}

```

The `Perms` implementation:

```
public class Perms {
    List<object> perms = new List<object>();

    public bool HasPermission<T>(T perm) {
        return perm == (GetPerm(typeof(T)) & perm);
    }
    dynamic GetPerm(Type permType) {
        foreach(var item in perms) {
            if(item.GetType() == permType)
                return item;
        }
        throw new Exception();
    }
}

```

That way you can use your new `CheckAccess` method like this:

```
bool b1 = CheckAccess(1, PermissionGroup1.CanDo11);
bool b2 = CheckAccess(3, PermissionGroup3.CanDo32);

```

Of course, you can rewrite `HasPermission` and `GetPerm` methods depending on your code rules (e.g. without dynamic and with reflection).
IMO it's better to change your enums to classes, instead of having different enum, have different classes and one enum (with different access level for example Level1, Level2, ... may be some extra level for future), and all of this classes inherit from base class (like PermisionAccessBase) which has one method (currently with this information): CheckAccess (as virtual), and one property which is of type Access Level Enum, All other classes inherit it in the way they want (can override base method but you can have a chance to call to your base).

It doesn't reduce the number of function you should write, but you can put common part of methods in base method and call it in overrided methods, Also it causes to separation of concept, I think the class currently you using for checking permission doesn't made for check permission and if is so, all different permission type checking gathered in one class which is not good.