BooleanSwitch.Enabled プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > BooleanSwitch.Enabled プロパティの意味・解説 

BooleanSwitch.Enabled プロパティ

スイッチが有効または無効かを示す値を取得または設定します

名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)
構文構文

例外例外
例外種類条件

SecurityException

呼び出し元に正しアクセス許可がありません。

解説解説

既定では、このフィールド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");
 }
 
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からBooleanSwitch.Enabled プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からBooleanSwitch.Enabled プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からBooleanSwitch.Enabled プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

BooleanSwitch.Enabled プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



BooleanSwitch.Enabled プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS