I want to deserialize a file. In one ofe my classes I have an array
like:
public class MyClass
{
public MyArray[] theArray;
}
i.e. an arry of an own defined class. While reading the file I only know
the dimension on the end of reading, so I keep the array elements in an
ArrayList "records". At the end I "only" have to assign the ArrayList to
the Array-field "theArray". And there is my problem.
arrayField.Fiel dType shows "MyArray[]", this is correct for me. If I try
with
arrayField.SetV alue(records.To Array(), instanceOfMyCla ss);
to assign the Array I get the error message that the objecttype can't be
converted to the destination type.
That's right, the object type is "object[]" and the destination type is
"MyArray[]".
How can I do the typecast at runtime?
Or is there another way to do this?
--
Sleepless in Berlin
Wernfried
like:
public class MyClass
{
public MyArray[] theArray;
}
i.e. an arry of an own defined class. While reading the file I only know
the dimension on the end of reading, so I keep the array elements in an
ArrayList "records". At the end I "only" have to assign the ArrayList to
the Array-field "theArray". And there is my problem.
arrayField.Fiel dType shows "MyArray[]", this is correct for me. If I try
with
arrayField.SetV alue(records.To Array(), instanceOfMyCla ss);
to assign the Array I get the error message that the objecttype can't be
converted to the destination type.
That's right, the object type is "object[]" and the destination type is
"MyArray[]".
How can I do the typecast at runtime?
Or is there another way to do this?
--
Sleepless in Berlin
Wernfried
Comment