Allow shorthand/inferred assignment of class fields #20819
Labels
Area-Language Design
Resolution-External
The behavior lies outside the functionality covered by this repository
I have a framework where I create "scenes" in C#, basically to describe a business process. I have these as classes and in them I define a bunch of fields to be used inside the class to operate on the business process (it's actually controlling DMX lights with the description of what should happen to the lights (the field variables) in the scene throughout the various class methods). So I have code like this:
My suggestion is to allow the use of
var
instead of having to have the class type in here twice, like we can do on stack variables, etc. So the code could be like this instead:Less typing, easier to read, less risk of error, and the compiler could easily infer the type.
Optionally it could also be used with readonly and access modifiers:
The goals of these classes (in my example) are to be as easy to read as possible (DSL), and allow the developer to focus on the functions of the scene with as little "plumbing" as possible.
The text was updated successfully, but these errors were encountered: