CRM 2011 CS: Assigning Lookup value

C# assign the contact to an account.
//C# assign the contact to an account.

Entity account = new Entity("account");
account["name"] = "Test Account1";
EntityReference primaryContactId = new EntityReference("contact", contactId);
account["primarycontactid"] = primaryContactId;