A
Alvin Bruney [MVP]
Sorry if this appears twice. Our mailserver died with that virus.
I see advice on this newsgroup about initializing strings to null. I
believe it is more prudent code to initialize a string variable to
string.empty instead of null. this leads to more robust code because a
programmer may try to touch this variable without testing it leading to a
null exception. Consider:
string str = null;
[snip]
str.length + 1;// blows here
string str = string.empty
[snip]
str.length + 1;//safe
Yes I know this is wide open for debate, i'm not looking for a fight
either.
I'm simply looking to test my theory to see if it holds up hence the post.
I
think programmers should always be on the defensive. ???
I see advice on this newsgroup about initializing strings to null. I
believe it is more prudent code to initialize a string variable to
string.empty instead of null. this leads to more robust code because a
programmer may try to touch this variable without testing it leading to a
null exception. Consider:
string str = null;
[snip]
str.length + 1;// blows here
string str = string.empty
[snip]
str.length + 1;//safe
Yes I know this is wide open for debate, i'm not looking for a fight
either.
I'm simply looking to test my theory to see if it holds up hence the post.
I
think programmers should always be on the defensive. ???