Type inference, new in C# 3.0

C# 3.0 introduced a var keyword that can be used to declare implicit types. The purpose of implicit types is to store any type in a variable. 

Example:

var granville = new Person();

Example withparameters:

var granville = new Person { FirstName = "Granville", LastName = Barnett", Age=20 };

Exampleanonymous type

var anon = new { FirstName = "Granville", LastName = "Barnett", Age = 20 };

Anomymoys type properties access: 7: 

var anon = new { FirstName = "Granville", LastName = "Barnett", Age = 20 };
anon.FirstName = "John";
anon.LastName = "Smith";
anon.Age = 30;

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!