2013年5月29日 星期三

C# Fundation, Part 4 (Fields & Properties)

Fields

1. Field is a variable of a class

2. If it’s readonly field, can only assign its value in declaration or constructor

image

 

Properties

1. Define a get and/or set accessor

2. Two usual implement types of property, automatical and full

3. In Visual Studio, code snippet are prop (for automatical) and propfull (for full)

image

 

Field & Property

1. A field needs memory to store data, but a property doesn’t

image

2. Different icons

image

沒有留言:

張貼留言