Initialisation of a class

Person example type

{ 
    public class Person
    {
        // property's
        public string FirstName { get; set; }

        public string LastName { get; set; }

        public int Age { get; set; }


        // ctor
        public Person() { }
    }

Class initialisation and setting the values of properties in C# 2.0

Person person = new Person(); 
person.FirstName = "Granville"; 
person.LastName = "Barnett"; 
person.Age = 20;

Class initialisation and setting the values of properties in C# 3.0

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

Class initialisation and setting properties direc to to a collection

Persion[] persons = { 
    new person{firstname ="a", lastname="b", age=30; 
    new person{firstname= "c", lastname="d", age=40; 
    new person{firstname = "f", lastname="g", age=60; 
}

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

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