In this article we will discuss about how to attach event receiver to list in SharePoint 2010. Also you can check out my previous posts on:
SPWeb mySite = SPContext.Current.Web;
SPList myList = mySite.Lists["MyListName"];
string assemblyName= "4 part Assembly name";
string eventReceiverName = "Namespace.ClassOfEventHandler";
lst.EventReceivers.Add(SPEventReceiverType.ItemAdded, assemblyName, eventReceiverName);
//Here we have added the event receiver to the ItemAdded event, you can also attach event receivers to ItemUpdated or ItemDeleted event.
catch (Exception ex)