Introduction:Microsoft has introduced the C# 3.0 with many key features. It reduces the work of the developers to write many lines of code to achieve the target. It will decrease the code size as well as the additional overhead of the servers.There are many features like Auto implemented property. Anonymous types, Partial methods, object initializes, implicitly typed local variables.New Features1. Auto Implemented PropertyThe property plays significant role to set and get the values. In the previous versions we were doing like need to set the values to the temporarily local variable. Now that work exactly reduced in the C# 3.0 version. Because it will be implicitly handled by the .Net compiler. Let's see the new version, Auto implemented property.[Access-modifier] data type [Name of the property]{get;set;}For example we are going to create one property for send email.public string FromID {get; set ;}public string ToID {get; set ;}public string Subject {get; set ;}public string Message {get; set ;}In previous version we have done like this.private string _FirstName;public string FirstName{ get { return _FirstName; } set { _FirstName = value; }}Here in C# 3.0, it became auto implemented property, that means in the runtime it will put one temp variable for assign the values by the compiler.2. Implicit Typed local variableThe new data type introduced in the C# 3.0. Normally when you store the elements in the string with the integer value we need to do the type casting. The variable that will be declared with the var keyword and it will be inferred by the compiler at the time of execution.var Total = 10 + 10;var iTotal = 10 + 15.5;var Name = "senthil" + "kumar";var Name = "senthil" + 10;Here what happens when you declare the var Total = 10 + 10, it will do the addition.On the other hand, when we declare this variable in the string what happens? Let's seestring name = 10 + 10;The result will be 1010. Because it will do the concatenation, until unless do the type casting. Here the expression will be inferred by the compiler.It can be used to create the array in the similar way.There are some restrictions to use this feature.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: