Created
April 28, 2012 15:00
-
-
Save ruselknow/2519678 to your computer and use it in GitHub Desktop.
Create class by name
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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| namespace ConsoleApplication2 | |
| { | |
| class Derived | |
| { | |
| public Derived() | |
| { | |
| } | |
| public static Derived getType() | |
| { | |
| return (Derived)Activator.CreateInstance(Type.GetType("ConsoleApplication2." + ClassList.Derived)); | |
| } | |
| } | |
| public enum ClassList | |
| { | |
| Derived= 1 | |
| } | |
| class Program | |
| { | |
| static void Main() | |
| { | |
| var tmp = Derived.getType(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment