What is the difference between a field variable and a local variable

A field variable is a variable that is declared as a member of a class. A local variable is avariable that is declared local to a method.

Showing Answers 1 - 1 of 1 Answers

p_kandukuri

  • Sep 12th, 2005
 

Field variables initializes where as local variables are not.

class test{

   int i;    //i values = 0  [field variable]
   string sName; //sName = null  [field variable]
   public void display(){
      int nSno; // nSno is not defined. [local variable]
   }

}


  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions