C# property accessor modifiers
In this chapter you will learn:
Description
The get and set accessors can have different access levels.
This would allow a property to have a public get and a private or protected set.
Example
In the following code example, notice that the set has a private access modifier and the get does not have any.
public string Name
{ //from w ww. ja va2 s .co m
get
{
return _name;
}
private set
{
_name = value;
}
}
Next chapter...
What you will learn in the next chapter:
C# Properties
C# Automatic properties
C# Static Properties
C# Abstract Properties
C# property accessor modifiers
C# read or write only propertyC# Automatic properties
C# Static Properties
C# Abstract Properties