The get keyword defines an accessor method in a property or indexer that retrieves the value of the property or the indexer element.
This is an example of a get accessor in a property named Seconds:
class TimePeriod
{
private double _seconds;
public double Seconds
{
get { return _seconds; }
set { _seconds = value; }
}
}
This is an example of a get accessor in an auto-implemented property:
class TimePeriod2
{
public double Hours { get; set; }
}
0 comments:
Post a Comment