I have the class below. _commandLine variable is declared as static. Does this variable will be shared between WkHtml class instances?
p.s. It would be cool to have Tool which would show such information in VS. For example developer select variable and get information about variable, is variable shared between classes, is it thread safe and etc.
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; }
}
}
static
variables are shared between all class instances.
I don't see any reason to why you should declare it as static?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With