Read-only and calculated properties - CSharp Custom Type

CSharp examples for Custom Type:Property

Introduction

A property is read-only if it specifies only a get accessor.

It is write-only if it specifies only a set accessor.

A property typically has a dedicated backing field to store the underlying data.

A property can also be computed from other data.

For example:

decimal currentPrice, sharesOwned;

public decimal Worth
{
  get { return currentPrice * sharesOwned; }
}

Related Tutorials