DEV Community

C# basic indexer question

bronxsystem on August 04, 2020

Learning C# and this is bit embarrassing but I wanted to make sure I understand everything and not skip over things I do not understand. is the li...
Collapse
 
pbeckerr profile image
PBeckerr • Edited

Its shorthand for a constructor, => can be used if you only have a single line of code in your block, but frankly i avoid it because for many it looks unfamiliar and you trade IMO space for lesser readability

this is the same in standard {} style

public Employee()
{
this.Roles = new ProjectRoles();
}

Collapse
 
bronxsystem profile image
bronxsystem • Edited

ohhhhh thank you very much sir. Turned light bulk on in my head.