标签:
Code in the Getter
Check the user‘s credentials
Check application state
Format the returned value
Log
Lazy Loading related data/object
Code in the Setter
Check the user‘s credentials
Check application state
Validate the incoming value
Log or change tracking
Format, convert, clean up
Best Practices
Do:
Add code in the getter to protect, format, initialize,...
Add code in the setter to protect, format, validate,...
Avoid:
Single character name
Abbreviations
Easy Way to Create
prop
propfull
C# Best Practices - Creating Good Properties
标签:
原文地址:http://www.cnblogs.com/lmfy/p/5125236.html