c# - Global variable and local variable clarification -


can please explain me this.

class program {     string opp;     private void method()     {         string u;         console.writeline(opp + u); // didn't initialize both local , global variables                                     // why local variable showing compile error                                     // use of unassigned local variable 'u'                                             } } 

when debug, global variable shows 'null'. like
global--> default null string , 0 value types??

when debug, global variable shows 'null'.

yes should cause haven't initialized , virtue of fact string reference type default initialized null wherein value types initialized 0 (false boolean).

again, key point string u; not class member; rather it's local variable scoped method method , should initialized before use either means of initializing explicitly or passing argument method , initialize it.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -