C# Questions and Answer

  1. What is Field in C#
    • In object-oriented programming, a field (also called data member or member variable) is a particular piece of data encapsulated within a class or object.
    • Fields, sometimes called class-level variables, are variables associated with classes or structures.
    • A field is a variable of any type that is declared directly in a class.
    •  A field can be used to explain the characteristics of an object or a class.
  2. What is Properties in C#
    • private variables can only be accessed within the same class (an outside class has no access to it). However, sometimes we need to access them – and it can be done with properties.
    • A property is a member that provides a flexible mechanism to read, write or compute the value of a private field.
    • A property is like a combination of a variable and a method, and it has two methods: a get and a set method