Lambda Expression #5
Answered
by
ChebanovDD
chauthanhdat
asked this question in
Q&A
|
Hi, thanks for your project. Can you explain why you use "=>" instead of "="? |
Answered by
ChebanovDD
May 25, 2022
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. |
0 replies
Answer selected by
ChebanovDD
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.