0

I have seen the following code in a property declaration:

public static int Year => 2017;

I understand that the => is the lambda operator.

Just looking for a simple explanation of the difference of doing this - I am guessing you can't set the value to any other value other than 2017?

public static int Year { get; set; }
Cœur
  • 37,241
  • 25
  • 195
  • 267
Ctrl_Alt_Defeat
  • 3,933
  • 12
  • 66
  • 116
  • See http://stackoverflow.com/questions/31764532/what-is-the-assignment-in-c-sharp-in-a-property-signature – L-Four Feb 07 '17 at 09:56
  • 1
    It is just this `public static int Year { get { return 2017; } }` – Ernis Feb 07 '17 at 09:57
  • 1
    It's expression bodied property, look here for more information: http://www.kunal-chowdhury.com/2014/12/csharp-6-expression-bodied-method.html#0d6hXAtdpHmuHU5I.97 – Maksim Simkin Feb 07 '17 at 09:57
  • Expression-Bodied [Properties](https://msdn.microsoft.com/en-us/library/x9fsa0sw.aspx) have no setter, they're new in C#6 – Tim Schmelter Feb 07 '17 at 09:57

0 Answers0