Object Initializer in C#

Below is a sample sourecode demonstrating the Object Initializer in C#

Object Initializer in C#

using System;

using System.Collections.Generic;

using System.Data;

using System.Linq;

namespace AbundantCode

{

internal class Program

{

//Object Initializer in C#

private static void Main(string[] args)

{

Employee emp = new Employee { Name = "Martin", EmpID = 1 };

Console.WriteLine(emp.Name);

Console.ReadLine();

}

}

public class Employee

{

public string Name { get; set; }

public int EmpID { get; set; }

}

}