Create an instance of a class from a string
Take a look at the Activator.CreateInstance method.
Take a look at the Activator.CreateInstance method.
With C# 7, which shipped with Visual Studio 2017 (Release 15.*), you are able to use Types in case statements (pattern matching): switch(shape) { case Circle c: WriteLine($”circle with radius {c.Radius}”); break; case Rectangle s when (s.Length == s.Height): WriteLine($”{s.Length} x {s.Height} square”); break; case Rectangle r: WriteLine($”{r.Length} x {r.Height} rectangle”); break; default: WriteLine(“<unknown shape>”); … Read more