C#: How can I create a class dynamically from text?
The following code is a really simple way to create a class dynamically from string.
dynamic data = new ExpandoObject();
IDictionary<string, object> dictionary = (IDictionary<string, object>)data;
dictionary.Add("FirstName", "Richard");
dictionary.Add("Surname", "Leeman");
Console.WriteLine(data.FirstName + " " + data.Surame);
dynamic data = new ExpandoObject();
IDictionary<string, object> dictionary = (IDictionary<string, object>)data;
dictionary.Add("FirstName", "Richard");
dictionary.Add("Surname", "Leeman");
Console.WriteLine(data.FirstName + " " + data.Surame);
Comments
Post a Comment