Gerson Kurz wrote:
- Klassen als Objekte. Ich kann in Python etwa schreiben
instance = { "foo" : class1, "bar" : class2 }[param]()
und erzeuge abhängig von param eine Klasse. (Gut, das Beispiel ist so etwas undurchsichtig, aber in real life benutze ich etwas ähnliches z.B. für einen Serial Protocol Analyzer. In C# : Fehlanzeige.
Das müsste eigentlich über Delegates funktionieren (wobei Du u.U. noch Wrapper-Factory-Funktionen einführen musst).
in C# mache ich das eigentlich genauso, ich *muss* aber new davor schreiben.
blablabla = new foo(bar);
Dabei ist foo(bar), wenn foo eine Klasse ist, eh keine gültige Syntax! In C++ könnte ich das ja noch verstehen, aber da gibt es ja auch dann delete dafür.
In C++ ist foo(bar) ein Cast, also das gleiche wie (foo)bar. Keine Ahnung, ob das in C# auch so ist. Ciao, Martin _______________________________________________ Python-de maillist - Python-de@starship.python.net http://starship.python.net/mailman/listinfo/python-de