There is no need to convert to object as all types in the .NET runtime inherit from object.
If you want to assign the members of the list Form1.AnimalTypes
to a combobox you should can just add them to the Items
collection and then you should set DisplayMember
to the name of the property you want to display and ValueMember
to the name of the property you want to bind.
comboBox.Items.AddRange(Form1.AnimalTypes);
comboBox.DisplayMember = "AnimalTypeName";
comboBox.ValueMember = "AnimalTypeId";
If you want to have just the conversion and the assignment to the combo box does not matter you can do the following:
object[] myArray = Form1.AnimalTypes.ToArray();
The converter class is needed for conversions that are not defined by an object's inheritance, i.e. use converters if you want to convert apples to oranges, but use casts if you want to convert appels or oranges to fruit. In c# 3.0 you can cast a complete collection by using the following snippet:
var newColOfBaseType = myList.Cast<BaseType>();
Using Linq you can also filte the entries of a given type from a collection and then extract a collection of that specific type:
var oranges = fruit.OfType<Orange>().Cast<Orange>();
Using Linq you can also use Select
to do a transformation:
var oranges = apples.Select(new Orange() { /* ... and initializers here ...*/});