Skip to content

Lambda Expression #5

Answered by ChebanovDD
chauthanhdat asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there! These are different things.

The = is an assignment operator.
The => is an expression-bodied member.

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.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ChebanovDD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants