ConfigurationManager.GetSection メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ConfigurationManager.GetSection メソッドの意味・解説 

ConfigurationManager.GetSection メソッド

メモ : このメソッドは、.NET Framework version 2.0 で新しく追加されたものです。

現在のアプリケーションの既定構成の、指定した構成セクションを取得します。

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

Public Shared Function GetSection
 ( _
    sectionName As String _
) As Object
Dim sectionName As String
Dim returnValue As Object

returnValue = ConfigurationManager.GetSection(sectionName)
public static Object GetSection (
    string sectionName
)
public:
static Object^ GetSection (
    String^ sectionName
)
public static Object GetSection (
    String sectionName
)
public static function GetSection
 (
    sectionName : String
) : Object

パラメータ

sectionName

構成セクションのパスと名前。

戻り値
指定した ConfigurationSection オブジェクト。セクションが存在しない場合は null 参照 (Visual Basic では Nothing)。

例外例外
例外の種類条件

ConfigurationErrorsException

構成ファイルを読み込むことができませんでした。

解説解説
使用例使用例

GetSection メソッドを使用して、構成のカスタム セクションを作成し、アプリケーション構成ファイルに保存する方法を次のコード例に示します。

' Get the a custom section. Show how to use the
' GetSection method.
Shared Sub GetCustomSection()
    ' Get the custom section.
    Dim custSection As CustomSection = _
    ConfigurationManager.GetSection("CustomSection")
    
    ' Read the custom section.
    Console.WriteLine( _
    "File name: {0} MaxIdleTime: {1} MaxUsers: {2}",
 _
    custSection.FileName, custSection.MaxIdleTime, _
    custSection.MaxUsers)
End Sub 'GetCustomSection

// Get the a custom section. Show how to use the
// GetSection method.
static void GetCustomSection()
{
    // Get the custom section.
    CustomSection custSection = 
        ConfigurationManager.GetSection("CustomSection") as CustomSection;
    
    // Read the custom section.
    Console.WriteLine("File name: {0} MaxIdleTime: {1} MaxUsers: {2}",
        custSection.FileName, custSection.MaxIdleTime, 
        custSection.MaxUsers);

}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「ConfigurationManager.GetSection メソッド」の関連用語

ConfigurationManager.GetSection メソッドのお隣キーワード
検索ランキング

   

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



ConfigurationManager.GetSection メソッドのページの著作権

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

©2026 GRAS Group, Inc.RSS