0

I have a simple class (that not inehited from IDisposable), that has some simple methods.

For access it, I do this:

var object= new class();

I saw in another code, one different way to instantiate:

var object= new class();
{

//do somenthing

}

what the curly braces do in this context ?

  • 1
    You're looking at an "Object initializer". You can read through the linked question for more info or just on msdn: http://msdn.microsoft.com/en-us/library/bb384062.aspx – Jeroen Vannevel Nov 14 '14 at 18:25
  • 1
    Your posted syntax for object initializer is bit wrong. It's `var object= new class() { //do somenthing };` – Rahul Nov 14 '14 at 18:28

0 Answers0