I suggest you ...

Suggestion: Add instance modifiers to C# (and other languages)

I'd like to be able to do

someFunctionReturningY(x){ somePropertyOfY=4; ... }.DoSomething();

It should also support casting without needing parentheses in the following type of statement:

Z zzz = (Z)functionReturningY{somePropertyOfZ=...; ... };

The same pattern should work for enums too apart from object instances. It is inspired by initializers in C#, e.g. var x = new Test(){someProperty=…}. It’s just a generalization of the same pattern.

E.g. at the scenario shown in the attached screenshots I want to modify an object that GetMetadataFromUI function returns and currently I’m forced to write it in a way that is much more verbose

0 votes
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