我通常会在VB.NET中将我的字符串变量定义为:
Dim f_sName as string=String.Empty
f_sName = "foo"
在 .net 中,由于字符串的不可变性质,有没有更好的方式来初始化字符串并处理 "Variable 'f_sName' is used before it has been assigned a value. A null reference exception could result at runtime." 警告?
对于那些没有接受无参数构造函数的类,比如 System.Net.Sockets.NetworkStream,最好的定义和初始化该类型变量的方法是什么?