【发布时间】:2011-09-02 10:58:24
【问题描述】:
我有下面的课程。 _commandLine 变量被声明为静态的。这个变量会在 WkHtml 类实例之间共享吗?
附言拥有可以在 VS 中显示此类信息的工具会很酷。例如开发人员选择变量并获取有关变量的信息、类之间是否共享变量、是否线程安全等。
public class WkHtml
{
private static string _commandLine;
public void AddCommandLine(object value)
{
AddCommandLine("{0}", value);
}
public void AddCmdWithCond(string value, bool condition, object compareValue)
{
AddCmdWithCond(value, condition, compareValue, "");
}
public void AddCmdWithCond(string value, bool condition, object compareValue, string defaultValue)
{
if (compareValue != null && !string.IsNullOrEmpty(compareValue.ToString()) && Helpers.GetBool(compareValue) == condition)
AddCommandLine("{0}", value);
else
if (defaultValue != null)
AddCommandLine("{0}", defaultValue);
}
public void AddCommandLine(object parameter, object value, object defaultValue)
{
if (value == null || string.IsNullOrEmpty(value.ToString()))
{
value = defaultValue;
}
AddCommandLine(parameter, value);
}
public void AddCommandLine(object parameter, object value)
{
if (value == null || string.IsNullOrEmpty(value.ToString())) return;
_commandLine = _commandLine + string.Format(parameter.ToString(), value) + " ";
}
public string GetCommandLine
{
get { return _commandLine; }
}
}
【问题讨论】: