c# create an instance of an object from string
c#, class
Solution
You'll need to use CodeDom to compile an in-memory assembly, and then use reflection to create the type.
Here's a sample article on MSDN that walks through the process of code generation.
Once you've compiled the code, you can use Activator.CreateInstance to create an instance of it.
Problem
I have a string variable contain: ``` string classCode = "public class Person { public string Name{get;set;} }"; ``` How can I create an instance of an object from the classCode ? like ``` object obj = CreateAnInstanceAnObject(classCode); ```