I use them if I need to cache a value and want to lazy load it.
private string _password;
private string Password
{
get
{
if (_password == null)
{
_password = CallExpensiveOperation();
}
return _password;
}
}
More Related Contents:
- C# software freezing when setting property to true
- Define if statement for property in C# [closed]
- Get property value from string using reflection
- Properties vs Methods
- Comparing object properties in c# [closed]
- Raise an event whenever a property’s value changed?
- Get properties in order of declaration using reflection
- Why use ‘virtual’ for class properties in Entity Framework model definitions?
- Properties vs. Fields: Need help grasping the uses of Properties over Fields
- Auto-implemented getters and setters vs. public fields
- Thread-safe List property
- Setting/getting the class properties by string name [duplicate]
- How to implement a read only property
- Why can’t I access C# protected members except like this?
- How to hide an inherited property in a class without modifying the inherited class (base class)?
- Why won’t anyone accept public fields in C#?
- “Strange” C# property syntax
- c# – How to iterate through classes fields and set properties
- Best practices: throwing exceptions from properties
- c# marking class property as dirty
- How to check all properties of an object whether null or empty?
- Are accessors (get and set functions) popular with C++ programmers?
- How to get current property name via reflection?
- C# 3.0 Auto-Properties – Is it possible to add custom behaviour?
- Custom browsable property for Form at design time
- Shortcut to create properties in Visual Studio?
- Getters, setters, and properties best practices. Java vs. C#
- WCF chokes on properties with no “set “. Any workaround?
- Setting properties via object initialization or not : Any difference ?
- What is the best practice for using public fields?