Lambda Expression #5
-
Hi, thanks for your project.
Can you explain why you use "=>" instead of "="? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi there! These are different things. The Expression-bodied read-only property (syntactic sugar): public int SelectedFillStrategyIndex => _fillStrategyDropdown.SelectedIndex; How the compiler sees it: public int SelectedFillStrategyIndex
{
get { return _fillStrategyDropdown.SelectedIndex; }
} Expression body definition is just a way to implement a read-only property in a very concise, readable form. |
Beta Was this translation helpful? Give feedback.
Hi there! These are different things.
The
=
is an assignment operator.The
=>
is an expression-bodied member.Expression-bodied read-only property (syntactic sugar):
How the compiler sees it:
Expression body definition is just a way to implement a read-only property in a very concise, readable form.