I suggest you ...

property and event setting block attached to C# type instance

Instead of having to write in C#

speechRecognizer = CreateSpeechRecognizer();
if (speechRecognizer != null)
{
speechRecognizer.SomeProperty = someValue;
speechRecognizer.SomeOtherProperty = someOtherValue;
speechRecognizer.SpeechRecognized += SpeechRecognized;
speechRecognizer.SpeechHypothesized += SpeechHypothesized;
speechRecognizer.SpeechRecognitionRejected += SpeechRecognitionRejected;
}

I'd prefer to write:

speechRecognizer = CreateSpeechRecognizer() {
SomeProperty = someValue,
SomeOtherProperty = someOtherValue,
SpeechRecognized += SpeechRecognized,
SpeechHypothesized += SpeechHypothesized,
SpeechRecognitionRejected += SpeechRecognitionRejected
}

that is after any Type I'd like to be able to add {...} block with assignments to its properties, like I can do when I create a new type.

Do note that I also would like this syntax and the existing new Type(...) {...} syntax (which is a subset of this one) to support assignment and removal of event handlers, not just setting of properties, as shown in the example above

1 vote
Vote
Sign in
(thinking…)
Password icon
Signed in as (Sign out)
You have left! (?) (thinking…)
birbilis shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

0 comments

Sign in
(thinking…)
Password icon
Signed in as (Sign out)
Submitting...

Feedback and Knowledge Base