.net value types
Please look at : http://msdn.microsoft.com/en-us/library/34yytbws.aspx
In there, I read : V开发者_运维问答alue types can have fields, properties, and events.
I know what properties and events mean but what does fields mean?
(This in preparation for MCPD certification)
From the documentation:
A field is a variable of any type that is declared directly in a class or struct. Fields are members of their containing type.
Fields are variables directly declared on the type:
struct MyStruc
{
private int myField;
public int MyProp
{
get { return _myField;}
set { _myField = value;}
}
}
There's a simple explination of fields on the MSDN site here.
This topic describes fields, which are objects or values contained in a class or struct. Fields allow classes and structures to encapsulate data.
and
Fields store the data a class needs to fulfill its design. For example, a class representing a calendar date might have three integer fields: one for the month, one for the day, and one for the year. Fields are declared within the class block by specifying the access level of the field, followed by the type of the field, followed by the name of the field.
精彩评论