New C# Language Feature: Automatic Properties

This feature is supported in C# only. Automatic properties provide a shorthand method for defining property procedures. Using Automatic properties, we can simplify writing property procedures. The syntax for a ItemClass using automatic properties is shown in the below code.



class ItemClass
    {
        private string ItemCode;
        private string ItemName;
        private string ItemDescription;
        private string ItemCategory;
        private double ItemPrice;
        private string ItemUnit;

			public string Code 		{ get; set; }
			public string Name 		{ get; set; }
			public string Description 	{ get; set; }
			public string Category 		{ get; set; }
			public double Price 		{ get; set; }
			public string Unit 		{ get; set; }  

	}



get and set after the property name creates a private field and default get/set accessors for each property by the compiler.