A Variable Defined Within A Block or Method or Constructor. Example: For (Int I 0 I 5 I++) ( ) Int I 0 Is The Local Variable

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

A field, is a member of a class or an object of any type that represents a memory

location for storing a value. i.e. a variable inside a class.


Fields are used to store data that must be accessible to multiple methods of a class and
available throughout the lifetime of an object. Fields enable a class or struct to store the
data with options to specify its accessibility at multiple levels.

Properties are named members of classes, structures, and interfaces.

A variable defined within a block or method or constructor. Example: for(int i=0;i<=5;i++){……} int i=0
is the local variable

Instance variables are created when an object is instantiated, and are accessible to all the
constructors, methods, or blocks in the class.

 readonly indicates that assignment to the field can only occur as part of the declaration or in a
constructor in the same class.

 auto-implemented properties make property-declaration more concise when no additional logic is


required in the property accessors. They also enable client code to create objects.

 Object Initializer assign values to accessible fields or properties of an object at creation after
invoking a constructor.

You might also like