locked
is field is variable ? RRS feed

  • Question

  • User-1682137340 posted

    hi i  am new to c#

    is field is variable ? 

    and can i assign value to field directly or using properties or both ?

    please help me , with short discription like yes or no 

    Thank you in advance

    Saturday, June 21, 2014 9:31 AM

Answers

  • User541108374 posted

    Hi,

    A field is a variable of any type that is declared directly in a class or struct. Fields are members of their containing type.

    I suggest you take a look at the official MSDN documentation over at http://msdn.microsoft.com/en-us/library/vstudio/ms173118(v=vs.100).aspx.

    So yes, a field is a variable but more precisely it's a class variable. You can assign it directly if you want but usually it's made private and exposed to other classes via properties.

    Grz, Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 21, 2014 10:26 AM