Autor Beitrag
DennisXX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133



BeitragVerfasst: Mo 06.02.12 23:28 
Hallo zusammen !

Ist es eigentich auch möglich, einem Delegaten nicht nur komplett deklarierte und ausprogrammierte Methoden zu übergeben, sondern auch bspw. anonyme Methoden (also das Prinziop einer anonymen Klasse in Java)? Und wäre so etwas wirklich guter Programmierstil?

Gruß
Dennis
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Di 07.02.12 00:05 
Uh, wann immer du anonyme Methoden oder Lambda-Ausdrücke verwendest, werden diese in Delegates umgewandelt ;) (die Konvertierung von Lambda-Ausdruck in Expression Tree mal außen vor gelassen). Schlechter Stil ist das also sicher nicht, sondern integraler Bestandteil von modernem C#-Code.
Oder wolltest du eigentlich etwas ganz anderes fragen?

_________________
>λ=
DennisXX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 133



BeitragVerfasst: Di 07.02.12 21:13 
Hi !

also ich meinte damit so etwas:

private delegate void aufruf(string s, string x){ //hier folgt direkt der Code der anonymen Methode};
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Di 07.02.12 22:35 
Da das nicht kompiliert, weiß ich immer noch nicht, was deine Frage ist. Die korrekte Syntax findest du hier: msdn.microsoft.com/e...ibrary/0yw3tz5k.aspx

_________________
>λ=