We have the cusotm permission in our list, so when an item is created in the list we have to add the specific user to the list item based on the business logic that was stored in the other list.
Following code we have used to add the user to an item as a contribute role:
// open the spsite object
SPSite spSite = new SPSite("http://webapplicationurl");
// open the spweb object
SPWeb spWeb = spSite.OpenWeb();
// Get the splist item object
SPListItem spItem = spWeb.Lists["MyList"].GetItemById(5);
// Create roll assignment object
roleAssignment = new SPRoleAssignment(spUser);
// Assign the roll defination
roleDefinition = spWeb.RoleDefinitions["Contribute"];
// Add the defination to rollassignment
roleAssignment.RoleDefinitionBindings.Add(roleDefinition);
// add the user roll to list item
spItem.RoleAssignments.Add(roleAssignment);
//update the list item
spItem.Update();