Skip to content

Instantly share code, notes, and snippets.

@ruselknow
Created April 28, 2012 15:00
Show Gist options
  • Save ruselknow/2519678 to your computer and use it in GitHub Desktop.
Save ruselknow/2519678 to your computer and use it in GitHub Desktop.
Create class by name
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