Dynamic Defination of class
-
I have two arrays name[]={a,b,c} value[]={1,2,3} My requirement is to define a class as myclass/*myclass will contain members as specified by name[] array*/ { string a; string b; string c: } at runtime and to create an object of myclass ,say myobj and set myobj.a=1; myobj.b=2; myobj.c=3; Point to note is that name[] and value[] array can be of any size and contain any value.They are not hard coded. I am at my wit's end to solve this problem.Please help. bidisha
-
I have two arrays name[]={a,b,c} value[]={1,2,3} My requirement is to define a class as myclass/*myclass will contain members as specified by name[] array*/ { string a; string b; string c: } at runtime and to create an object of myclass ,say myobj and set myobj.a=1; myobj.b=2; myobj.c=3; Point to note is that name[] and value[] array can be of any size and contain any value.They are not hard coded. I am at my wit's end to solve this problem.Please help. bidisha
You need C# 3.0, it would handle this, no trouble. Why not use a dictionary to define variables like this ? Christian Graus - Microsoft MVP - C++