pls explain the difference between local,class-level and public variables.
and difference between method that is void and method is not void...
thanks for answer for advance
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jun 19, 2013, 5:55 AM
AlexPosted Jun 23, 2013, 8:04 AM
Sunny SharmaPosted Jun 19, 2013, 1:45 AM
In your question, Local, Class-Level and Public variables, all stand in regard of the their Scope while being accessed inside your program.
In case when a variable is declared inside a class we call it local to that class. It also would be a Class-Level variable. A public variable is that you can access from outside the class.
See the example below:
------------------------------
{ private string MY_SSN; public string MY_NAME;inthiyazPosted Jun 19, 2013, 1:04 AM
class level: entire class level and can not be accessible out side of the class scope.
public:within the name space, can be access any class within the name space and cant accessible out side of the name space.
following snippet will help for better understand..
namespace nA
{
//Global declarations
public string aglobal="public/global level";
class A
{
//Class level declarations
string aclass="class level";
public void methodA()
{
//Method level declarations
string alocal="method level";
console.write(a);
}
}
class B
{
string aclass="class level";
public void methodA()
{
string alocal="method level";
console.write(a);
}
}
}