Add a quick refactoring , About delegate and event #7538
Replies: 2 comments 10 replies
-
@zms9110750 can you change your post to use the term 'property/properties' instead of 'attribute/attributes'? "Attributes" are something else entirely in C#. Namely |
Beta Was this translation helpful? Give feedback.
-
@zms9110750 Thanks for updating the original post. I will say that I am a bit confused about the request. It's worth noting that just like fields/properties, events also support the dual-representation of storage vs computed. For example, here is an event which will be backed with explicit storage in the type: public event Action E; With this declaration, consumers can do However, you are not required to use the form that specifies explicit storage. You can also use the property-like form: public event Action { add { ... } remove { ... } }` And you can control how the add/remove actually computes at runtime. THe consumer's perspective will be the same though, They'll still do: So... it's unclear what change you'd actually like in the language, as i think the language does work in teh way you're asking for. -- However, it's very possible i'm misunderstanding your post. If you can shed some more light on this, that would be great. Thank you! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Similar to encapsulating fields as property and reducing complete property to automatic property,
The syntax and property of events are similar, and I believe they should also have similar refactoring.
Compared to refactoring to simplify developer operations, I need this menu to tell newcomers that events and delegates are different, and how they are different.
The refactoring of fields helped me understand fields, property, and automatic property.
This refactoring can also help others understand delegate and event.
Beta Was this translation helpful? Give feedback.
All reactions