H
Håkan Johansson
error CS0445: Cannot modify the result of an unboxing conversion
I'm quite new to C# and can't really see how to get rid of the above error.
I have an ArrayList instance to which I add two types of elements. The first
type of element is a class, the other type of element is a struct. Sometimes
I need to change the field values of the elements held by the ArrayList. In
the case of the class type element, this is no problem. However, in the case
of the struct type element, C# won't allow it. First of all, I don't really
understand why. Secondly, do I really have to create a new class with
similar content of the struct to get rid of this error?
Regards Carl Johansson
I'm quite new to C# and can't really see how to get rid of the above error.
I have an ArrayList instance to which I add two types of elements. The first
type of element is a class, the other type of element is a struct. Sometimes
I need to change the field values of the elements held by the ArrayList. In
the case of the class type element, this is no problem. However, in the case
of the struct type element, C# won't allow it. First of all, I don't really
understand why. Secondly, do I really have to create a new class with
similar content of the struct to get rid of this error?
Regards Carl Johansson