What are Object Initializers?

 Posted by Tripati_tutu on 4/30/2011 | Category: C# Interview questions | Views: 3626 | Points: 40

The Object initializers are the features for programming concepts which was introduced in C#.Net.

The aim of using Object Initializers is to intializing the accessible fields or properties
of an object without the need to write any parameterized constructor or separate

using System; 

class Student
int rollno;
string stdName;

static void Main()
Student s = new Student() { rollno=1,stdName="Ramesh" }; //Object Initializer

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response