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.
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 attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jun 19, 2013, 1:55 AM EDT
inthiyaz2 reputationPosted Jun 18, 2013, 9:04 PM EDT
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);
}
}
}
Sunny SharmaRank #223 · 11.1K reputationPosted Jun 18, 2013, 9:45 PM EDT
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:
------------------------------
by putting a "void" keyword we declare that the method is going to return nothing, It is just intended to do something but return nothing. Whereas if you declare a return Data type, then the method is supposed to return that Data type from inside of the method, like:
--------------------------------------------
Alex50 reputationPosted Jun 23, 2013, 4:04 AM EDT