2

I have following c# code. i don't know the meaning of => operator in this code!!

public class ClassA: ClassB
{
    public string Type => "article";
}
ahmad valipour
  • 293
  • 2
  • 11

1 Answers1

6

This is a shorthand syntax that was introduced in C# 6. The sample that you provided is a shorthand for readonly property and it is equivalent to

public class ClassA: ClassB
{
    public string Type 
    {
        get { return "article"; }
    }
}
Sebastian Brosch
  • 42,106
  • 15
  • 72
  • 87
dotnetom
  • 24,551
  • 9
  • 51
  • 54