BooleanSwitch.Enabled Propiedad
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Obtiene o establece un valor que indica si el modificador está habilitado o deshabilitado.
public:
property bool Enabled { bool get(); void set(bool value); };
public bool Enabled { get; set; }
member this.Enabled : bool with get, set
Public Property Enabled As Boolean
Valor de propiedad
true
si el modificador está habilitado; de lo contrario, false
. De manera predeterminada, es false
.
Excepciones
El autor de llamada no dispone del permiso requerido.
Ejemplos
En el ejemplo de código siguiente se crea y BooleanSwitch se usa el modificador para determinar si se va a imprimir un mensaje de error. El modificador se crea en el nivel de clase. El Main
método pasa su ubicación a MyMethod
, que imprime un mensaje de error y la ubicación donde se produjo el error.
public ref class BooleanSwitchTest
{
private:
/* Create a BooleanSwitch for data.*/
static BooleanSwitch^ dataSwitch = gcnew BooleanSwitch( "Data","DataAccess module" );
public:
static void MyMethod( String^ ___location )
{
//Insert code here to handle processing.
if ( dataSwitch->Enabled )
Console::WriteLine( "Error happened at {0}", ___location );
}
};
int main()
{
//Run the method that writes an error message specifying the ___location of the error.
BooleanSwitchTest::MyMethod( "in main" );
}
//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 that writes an error message specifying the ___location of the error.
MyMethod("in Main");
}
'Class level declaration.
' Create a BooleanSwitch for data.
Private Shared dataSwitch As New BooleanSwitch("Data", "DataAccess module")
Public Shared Sub MyMethod(___location As String)
'Insert code here to handle processing.
If dataSwitch.Enabled Then
Console.WriteLine(("Error happened at " + ___location))
End If
End Sub
'Entry point which delegates to C-style main Private Function
Public Overloads Shared Sub Main()
Main(System.Environment.GetCommandLineArgs())
End Sub
Overloads Public Shared Sub Main(args() As String)
'Run the method that writes an error message specifying the ___location of the error.
MyMethod("in Main")
End Sub
Comentarios
De forma predeterminada, este campo se establece false
en (deshabilitado). Para habilitar el modificador, asigne este campo el valor de true
. Para deshabilitar el modificador, asigne el valor a false
. El valor de esta propiedad viene determinado por el valor de la propiedad SwitchSettingde clase base .