SharePoint Check User Permission

This is code snippet to check if user has role permission

/// Find the particular role definition to check agaionst the user has permisson
SPRoleDefinition roleDefinition = web.RoleDefinitions.GetByType(SPRoleType.Administrator);
SPUser siteUser = web.SiteUsers[“SP\\mukesh”];

///Get all permission for the selected user
SPPermissionInfo userPermissions = web.GetUserEffectivePermissionInfo(siteUser.LoginName);

///Check role is is assigned to the user
var memberof = userPermissions.RoleAssignments.Where(role => role.RoleDefinitionBindings.Contains(roleDefinition)).Select(roleMember => roleMember.Member).ToList();