Visual Studio 2010 - Visual C#
set (C# Reference)
The set keyword defines an accessor method in a property or indexer that assigns the value of the property or the indexer element. For more information and examples, see Properties (C# Programming Guide), Auto-Implemented Properties (C# Programming Guide), and Indexers (C# Programming Guide).
This is an example of a set accessor for a property named Seconds:
C#
class TimePeriod { private double _seconds; public double Seconds { get { return _seconds; } set { _seconds = value; } } }
This is an example of a set accessor in an auto-implemented property:
C#
class TimePeriod2 { public double Hours { get; set; } }
C# Language Specification
For more information, see the C# Language Specification. The language specification is the definitive source for C# syntax and usage.
See Also
Reference
Concepts
Other Resources
Community Content
SJ at MSFT
This would be better if...
With Auto Setters/Getters, show how to modify the hidden private values.
Edit by SJ at MSFT: See http://msdn.microsoft.com/en-us/library/bb384054.aspx for a full example.
Edit by SJ at MSFT: See http://msdn.microsoft.com/en-us/library/bb384054.aspx for a full example.