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

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -