Properties

Some properties in C# help us to write fewer, it called syntatic sugar.

Before:

class Invader
{
    private MapLocation _location;

    public MapLocation GetLocation()
    {
        return _location;
    }

    private void SetLocation(MapLocation value)
    {
        _location = value;
    }
}

After:

public MapLocation Location { get; private set; }

results matching ""

    No results matching ""