P
Paul Jones
Hi,
I need to create a new object of the same type as another variable is.
Since I do not know the exact type (it varies within the function), I
need to get the original type using GetType(). I've found somewhere on
the internet that the new variable can be created this way:
Object celldata = row.ItemArray.GetValue(i);
Object newobj = Activator.CreateInstance(celldata.GetType());
The second line throws an exception "A constructor without parameters is
not defined for this object." Why? celldata is typed as string at this
moment...
Thanks for any help...
With regards
Paul Jones
I need to create a new object of the same type as another variable is.
Since I do not know the exact type (it varies within the function), I
need to get the original type using GetType(). I've found somewhere on
the internet that the new variable can be created this way:
Object celldata = row.ItemArray.GetValue(i);
Object newobj = Activator.CreateInstance(celldata.GetType());
The second line throws an exception "A constructor without parameters is
not defined for this object." Why? celldata is typed as string at this
moment...
Thanks for any help...
With regards
Paul Jones