C# - terminology - class, member, field, property and method

class

The definition of a type; specifically a type that contains data and the methods that operate on that data. Compare to struct.

member

A field, property or method within a class.

field

A data member that is accessed directly. Also called a member variable.

property

A data member that is accessed through a property acessor (via generated get_Prop() and set_Prop() methods).

method

A procedure or function.

An example:


  class Test // a class
  {
      private string _firstName; // a member. a field.
      public string FirstName // a member. a property
      {
          get { return _firstName; }
      }
      
      public void Print() // a member. a method
      {
          Console.WriteLine("Hello " + _firstName);
      }
  }
  

Ads by Google



Ask a question, send a comment, or report a problem - click here to contact me.

© Richard McGrath