I have defined my extended class this way:
public class ExtendedAttributeMetadata : AttributeMetadata
{
public bool IsTwoOption { get; set; }
}
But upon copying the source array of type AttributeMetadata[] to my new destination array ExtendedAttributeMetadata[], i am getting InvalidCastException:
"At least one element in the source array could not be cast down to the destination array type."
Code:
AttributeMetadata[] attributes;
//...
ExtendedAttributeMetadata[] extendedAttributes = new ExtendedAttributeMetadata[attributes.Length];
attributes.CopyTo(extendedAttributes, 0);
ADDED:
Where AttributeMetadata is derived from MetadataBase
public class AttributeMetadata : MetadataBase
And MetadataBase is an abstract class.
public abstract class MetadataBase : IExtensibleDataObject
Please suggest the best and optimal way of copying in my case.
ExtendedAttribute.ExtendedAttributeMetadatainto an array of typeExtendedAttributeMetadata. That just isn't possible.