krishna
krishna

Reputation: 1351

.net value types

Please look at : http://msdn.microsoft.com/en-us/library/34yytbws.aspx

In there, I read : Value 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)

Upvotes: 0

Views: 145

Answers (3)

Jamie Dixon
Jamie Dixon

Reputation: 54011

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.

Upvotes: 0

Oded
Oded

Reputation: 499312

Fields are variables directly declared on the type:

struct MyStruc
{
  private int myField;

  public int MyProp
  {
    get { return _myField;}
    set { _myField = value;}
  }
}

Upvotes: 3

Darin Dimitrov
Darin Dimitrov

Reputation: 1039428

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.

Upvotes: 3

Related Questions