Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For the second one you can write this:

    public int Y => 5;


It isn't the same. With immutable properties the constructor can change the value of Y based on its own decision logic. So 5 is just a default and the constructor may change it. That allows for multiple constructors, some that set the value some that don't.

If the value is always going to be 5, then use a const.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: