The SPWeb has a RoleDefinitions property that return a list of SPRoleDefinition.
Each SPRoleDefinition is a permission level ; for instance in the next code snippe,t web.Roledefinitions will return a collection of 6 roles; they match the permission Levels of the web site :
If you want to assign a permission level to a user on a specific list, you need to create a new RoleAssignement (SPRoleAssignment class) that can be added to the SPList. The new permission must be linked to the role assignment by adding it to a collection called RoleDefinitionBindings.
SPWeb web =SPControl.GetContextWeb(HttpContext.Current); // use RunWithElevatedPrivilege here
SPList myList = web.Lists["MyList"];
SPRoleDefinition fullRoleDef = web.RoleDefinitions["Full Control"];
SPUser user = web.EnsureUser(“LITWARE\SERGE”);
SPRoleAssignment newRoleassignment= new SPRoleAssignment(user);