What is different between scope variable and public variable of a variable in C#? -
What is different between scope variable and public variable of a variable in C#? -
this question has reply here:
variable scope confusion in c# 4 answerswhat different between scope variable , public variable of variable in c# can declare variables @ 4 different locations in programs meant "scope" of variable? think of scope of variable "the scope of particular variable range within program's source code in variable recognized compiler".
if reading of question correct, looking contrast scope (local, instance, static, etc.) visibility (public, private, protected, internal). these 2 concepts independent (i said "nearly", because variables of local scope not have visibility). allow command both lifetime , accessibility of variables.
the scope controls lifetime of variable, letting determine when comes existence , when becomes unavailable. naturally, scope constraints "the range within program's source code in variable recognized compiler". however, beingness recognized compiler not sufficient programme access variable: if compiler recognizes variable private, wouldn't allow programme access outside context variable visible (e.g. methods of class).
essentially, scope , visibility command 2 different aspects of accessibility work decide range within program's source code in variable can used code tries access it.
c#
Comments
Post a Comment