0

Can someone explain to me what these code snippets do?

class Pirat
{
        public string Name => "Jack";
}

class Pirat
{
  private string _name;

  public string Name
  {
    get => _name;
    set => Name = value;
            
  }
}

These code examples are not in the same code

1 Answers1

0

"New" (actually quite old by now) syntax to define properties (and methods actually) with Lambda's.

The => should have been a hint - that is the same that is used in any other Lambda setup in C# (like LINQ).

TomTom
  • 61,059
  • 10
  • 88
  • 148