BooleanSwitch.Enabled プロパティ
アセンブリ: System (system.dll 内)

Dim instance As BooleanSwitch Dim value As Boolean value = instance.Enabled instance.Enabled = value
/** @property */ public boolean get_Enabled () /** @property */ public void set_Enabled (boolean value)
スイッチを有効にする場合は true。それ以外の場合は false。既定値は false です。


既定では、このフィールドは false (無効) に設定されます。スイッチを有効にするには、このフィールドに値 true を設定します。スイッチを無効にするには、値を false に設定します。このプロパティの値は、基本クラス プロパティ SwitchSetting の値によって決まります。
![]() |
---|
このメソッドは SecurityAction.LinkDemand フラグを使用して、信頼関係のないコードからの呼び出しを防ぎます。SecurityPermissionAttribute.UnmanagedCode アクセス許可は、直前の呼び出し元にのみ要求されます。信頼性が一部しか確認されていないコードから呼び出すことができるコードの場合、ユーザー入力を検証せずに Marshal クラスに渡すことは避けてください。LinkDemand メンバの使用に関する重要な制約事項については、「Demand と LinkDemand」を参照してください。 |

BooleanSwitch を作成し、スイッチを使用してエラー メッセージを出力するかどうかを決定するコード例を次に示します。スイッチはクラス レベルで作成されます。Main メソッドは、その位置をエラー メッセージとエラーの発生場所を出力する MyMethod に渡します。
'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 'MyMethod '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 '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"); }
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. */ private static BooleanSwitch dataSwitch = new BooleanSwitch("Data", "DataAccess module"); public static void MyMethod(String location) { //Insert code here to handle processing. if (dataSwitch.get_Enabled()) { Console.WriteLine("Error happened at " + location); } } //MyMethod public static void main(String[] args) { // Run the method that writes an error message specifying the location // of the error. MyMethod("in main"); } //main
//Class level declaration. /* Create a BooleanSwitch for data.*/ static var dataSwitch : BooleanSwitch = new BooleanSwitch("Data", "DataAccess module"); static public function MyMethod(location : String) { //Insert code here to handle processing. if(dataSwitch.Enabled) Console.WriteLine("Error happened at " + location); } public static function Main(args : String[]) { //Run the method that writes an error message specifying the location of the error. MyMethod("in Main"); }


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からBooleanSwitch.Enabled プロパティを検索する場合は、下記のリンクをクリックしてください。

- BooleanSwitch.Enabled プロパティのページへのリンク