wenn es nur um das Speichern der Objekte in einer Liste geht, kann man eine Hashtable nutzen oder noch besser (ab .NET 2.0) eine SortedList
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
| enum MyEnum { Button, Label, Form } ..... SortedList<MyEnum, object> list = new SortedList<MyEnum, object>(); ..... list[MyEnum.Button] = new Button(); ..... if (list[MyEnum.Button] is Button) MessageBox.Show("OK"); |
Problem ist das Erzeugen der Objekte a lá
Delphi-Quelltext
1:
| EnumTrans[abListe].Create(nil) |
so geht es in C# ohne Weiteres nicht.
eine Möglichkeit wäre die Reflection zu nutzen