use object initializers
Published: 25. November 2011 | Updated: 25. November 2011License: Microsoft Public License (MS-PL)
Categories: Framework
Tags: C#
Example class
public class MyClass { public int A { get; set; } public string B { get; set; } }
Code
// initialize properties var obj = new MyClass { A = 1, B = "b" };
| Send us feedback about this snippet » |





