本文整理匯總了C#中System.Diagnostics.BooleanSwitch類的典型用法代碼示例。如果您正苦於以下問題:C# BooleanSwitch類的具體用法?C# BooleanSwitch怎麽用?C# BooleanSwitch使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BooleanSwitch類屬於System.Diagnostics命名空間,在下文中一共展示了BooleanSwitch類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: BooleanSwitch
// Class level declaration.
/* Create a BooleanSwitch for data.*/
static BooleanSwitch dataSwitch = new BooleanSwitch("Data", "DataAccess module");
static public void MyMethod(string location) {
//Insert code here to handle processing.
if(dataSwitch.Enabled)
Console.WriteLine("Error happened at " + location);
}
public static void Main(string[] args) {
//Run the method which writes an error message specifying the location of the error.
MyMethod("in Main");
}
示例2: BooleanSwitch
private static BooleanSwitch boolSwitch = new BooleanSwitch("mySwitch",
"Switch in config file");
public static void Main( )
{
//...
Console.WriteLine("Boolean switch {0} configured as {1}",
boolSwitch.DisplayName, boolSwitch.Enabled.ToString());
if (boolSwitch.Enabled)
{
//...
}
}