Created
September 28, 2017 10:25
-
-
Save NMZivkovic/5b56d53d4e78cc5fe5d79ead7a764376 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var shapes = new Dictionary<string, object> | |
{ | |
{ "FirstShape", new Rectangle(1, 1) }, | |
{ "SecondShape", new Circle(6) } | |
}; | |
foreach(var shape in shapes) | |
{ | |
if (shape.Value is Rectangle) | |
{ | |
var height = ((Rectangle)shape.Value).Height; | |
Console.WriteLine(height); | |
} | |
else if (shape.Value is Circle) | |
{ | |
var height = ((Circle)shape.Value).Radius * 2; | |
Console.WriteLine(height); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment