Discussion: event subscription in object initializers #307
Replies: 5 comments 2 replies
-
I'd love to see this. It'd allow several construction/initialisation operations to become single expressions, which play nicely with other C# features that reduce nesting such as expression bodies, null coalescing, ternary conditionals... There's some support for this idea on StackOverflow too. |
Beta Was this translation helpful? Give feedback.
-
I would love this! |
Beta Was this translation helpful? Give feedback.
-
No. The feature that should be implemented is #1652. It covers the requested feature and does so much more. |
Beta Was this translation helpful? Give feedback.
-
I would really like to see this feature added. It would tidy up a lot of existing initialization code where you have to do the following following if you want to use Object Initialization:
I'm curious as to why this wasn't added when the Object Initializer functionality was introduced? It looks like a trivial thing to add. |
Beta Was this translation helpful? Give feedback.
-
I'll champion this. |
Beta Was this translation helpful? Give feedback.
-
Moved from dotnet/roslyn#5365
Extend object initializer block to support event subscriptions:
->
Open question: should we allow multiple event subscriptions for a single event at a time?
Beta Was this translation helpful? Give feedback.
All reactions