I want to dynamically create a class in c#.net.
I tried using anonymous methods since the number of member variables is given dynamically,
i tried like this,
string element = "element";
string str = String.Empty;
for (int i = 0; i < elementsCount; i++)
{
str = String.Concat(str, element + i, "=String.Empty", ",");
if (i == elementsCount - 1)
str = String.Concat(str, element + i, "=String.Empty");
}
string s = "new{" + str + "}";
var a=s;
and
i want to assign the class ‘a’ like ObservableCollection but i could not do this.
Is there any way to do these two??
but this is not the right way i guess;
Try look here:
Dynamic in C# 4.0: Introducing the ExpandoObject