Similar question: Passing int list as a parameter to a web user control
Is there any similar example for enum type?
I am creating a asp.net custom control in which I want to pass comma separated list of enums as property.
I am writing a TypeConverter
for converting comma separated string values to List of Enum.
In the ConvertTo
method,
How to create InstanceDescriptor
object for list of enum?
My current code is as follows:
//enum
public enum MyEnum {Hello, World}
//main method
List<MyEnum> list = new List<MyEnum>();
list.Add(MyEnum.Hello);
list.Add(MyEnum.World);
ConstructorInfo constructor = typeof(List<MyEnum>).GetConstructor( Type.EmptyTypes );
InstanceDescriptor idesc = new InstanceDescriptor(constructor, list);
This fails with the message
Length mismatch
I wonder why