What does this code mean: public bool HasBars => BarList != null && BarList.Count > 0;?

95 views Asked by At

I have code on C# and dont understend what it's mean. Is there any analogs of this code&

public bool HasBars => BarList != null && BarList.Count > 0;
2

There are 2 answers

3
Code Pope On BEST ANSWER

Maybe the point which is confusing you, is the expression-bodied-member which is just a syntactic sugar of C# 6 version.

It is equal to:

public bool HasBars 
{
    get
    {
        return BarList != null && BarList.Count > 0;
    }
}
2
opewix On

It's the same as:

public bool HasBars
{
    get
    {
        return BarList != null && BarList.Count > 0;
    }
}