Share via


get (C# Reference) 

Defines an accessor method in a property or indexer that retrieves the value of the property or the indexer element. See Properties and Indexers for more information.

This is an example of a get accessor in a property called Seconds:

class TimePeriod
{
    private double _seconds;
    public double Seconds
    {
        get { return _seconds;  }
        set { _seconds = value; }
    }
}

C# Language Specification

For more information, see the following sections in the C# Language Specification:

  • 1.6.6.2 Properties

  • 10.6.2 Accessors

See Also

Reference

C# Keywords

Concepts

C# Programming Guide

Other Resources

C# Reference