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

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

Configuration.GetSection メソッド

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

指定した ConfigurationSection オブジェクト返します

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

Public Function GetSection ( _
    sectionName As String _
) As ConfigurationSection
Dim instance As Configuration
Dim sectionName As String
Dim returnValue As ConfigurationSection

returnValue = instance.GetSection(sectionName)
public ConfigurationSection GetSection (
    string sectionName
)
public:
ConfigurationSection^ GetSection (
    String^ sectionName
)
public ConfigurationSection GetSection (
    String sectionName
)
public function GetSection (
    sectionName : String
) : ConfigurationSection

パラメータ

sectionName

返されるセクションへのパス

戻り値
指定した ConfigurationSection オブジェクト

解説解説
使用例使用例

GetSection メソッド使用してカスタム セクション情報アクセスする方法次のコード例示します

' Get a custom section.
Shared Sub GetSection() 
    Try
        
        Dim customSection As CustomSection
        
        ' Get the current configuration file.
        Dim config _
        As System.Configuration.Configuration = _
        ConfigurationManager.OpenExeConfiguration( _
        ConfigurationUserLevel.None)
        
        customSection = _
        config.GetSection("CustomSection")
        Console.WriteLine( _
        "Section name: {0}", _
        customSection.SectionInformation.Name)
    
    Catch err As ConfigurationErrorsException
        Console.WriteLine(err.ToString())
    End Try

End Sub 'GetSection
 
// Get a custom section.
static void GetSection()
{
    try
    {

        CustomSection customSection;

        // Get the current configuration file.
        System.Configuration.Configuration config =
                ConfigurationManager.OpenExeConfiguration(
                ConfigurationUserLevel.None) as Configuration;

        customSection = 
            config.GetSection("CustomSection") as CustomSection;
        
        Console.WriteLine("Section name: {0}", 
            customSection.SectionInformation.Name);

    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine(err.ToString());
    }

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



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

辞書ショートカット

すべての辞書の索引

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

   

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



Configuration.GetSection メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS