What is the difference between field and a variable?
what is the diff between a field and a variable?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 7, 2013, 6:51 AM EDT
This contrasts with a local variable which is only visible within the block in which it is defined. This block may either be an entire method or property or only part of it such as a loop statement.
For example:
class MyClass
{
public int MyInt; // this is a field or class level variable
public void MyMethod()
{
int i = 3; // this is a local variable
Console.WriteLine(i);
}
}