K
Kishore
Hi
I have a class (type - MyClass). I need to create an instance of this
class and then create an array of type MyClass and intialize this
array with the instance.
I am able to create the class and array but not sure how to
initialize.
Type myClassType = Type.GetType("MyClass,MyAssembly");
ConstructorInfo cinfo = myClassType.GetConstructor(new Type[]{});
object myClassObj = cinfo.Invoke(null);
Type myClassArrayType = Type.GetType("MyClass[], MyAssembly");
cinfo = myClassArrayType.GetConstructor(new Type[]{typeof(int)});
object myClassArray = cinfo.Invoke(new object[]{1});
//HOW CAN I DO myClassArray[0] = myClassObj using Reflection.
Please suggest
Thanks
I have a class (type - MyClass). I need to create an instance of this
class and then create an array of type MyClass and intialize this
array with the instance.
I am able to create the class and array but not sure how to
initialize.
Type myClassType = Type.GetType("MyClass,MyAssembly");
ConstructorInfo cinfo = myClassType.GetConstructor(new Type[]{});
object myClassObj = cinfo.Invoke(null);
Type myClassArrayType = Type.GetType("MyClass[], MyAssembly");
cinfo = myClassArrayType.GetConstructor(new Type[]{typeof(int)});
object myClassArray = cinfo.Invoke(new object[]{1});
//HOW CAN I DO myClassArray[0] = myClassObj using Reflection.
Please suggest
Thanks