Created
October 12, 2014 16:18
-
-
Save dariusz-wozniak/3cc70aa649761d6a0076 to your computer and use it in GitHub Desktop.
Nested Object Initializer Syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NestedInitializerExample | |
{ | |
public void Init() | |
{ | |
Rectangle rectangle = new Rectangle | |
{ | |
P1 = { X = 0, Y = 1 }, | |
P2 = { X = 2, Y = 3 } | |
}; | |
} | |
} | |
public class Point | |
{ | |
public int X { get; set; } | |
public int Y { get; set; } | |
} | |
public class Rectangle | |
{ | |
public Rectangle() | |
{ | |
P1 = new Point(); | |
P2 = new Point(); | |
} | |
public Point P1 { get; set; } | |
public Point P2 { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment