Code for adding Content Type through Visual Studio (Windows Form- For SharePoint 2010)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Microsoft.SharePoint; namespace Demo { public partial class Form1 : Form { private const string siteurl = "http://win-5dlgan2f7s8:21905/CrimsonConsultingHR/Demo/"; public Form1() { InitializeComponent(); } private void CreatecontentType_Click(object sender, EventArgs e) { using (var site = new SPSite(siteurl)) { var web = site.RootWeb; var empFieldName = web.Fields.Add("Employee", SPFieldType.Boolean, true); var employee = web.Fields.GetFieldByInternalName(empFieldName); employee.Group = "AayushContentType"; employee.Update(); var rateFieldName = web.Fields.Add("Salary/Rate", SPF