c# - Local constant initialised to null reference -
i have read c# allows local constants initialised null reference, example:
const string mystring = null;
is there point in doing however? possible uses have?
my guess because null is valid value can assigned reference types , nullable values types. can't see reason forbid this.
there might far off edge cases can useful, example multi targeting , conditional compilation. ie want define constant 1 platform define null due missing functionality.
ex, of possible usefull usage:
#if (silvelight) public const string defaultname = null; #else public const string defaultname = "win7"; #endif
Comments
Post a Comment