共用方式為


SectionInformation.IsLocked 屬性

定義

取得值,指出是否已鎖定關聯的組態區段。

public:
 property bool IsLocked { bool get(); };
public bool IsLocked { get; }
member this.IsLocked : bool
Public ReadOnly Property IsLocked As Boolean

屬性值

如果已鎖定此區段,則為 true,否則為 false

範例

本節中的範例示範如何在存取組態檔中的相關區段信息之後取得 IsLocked 屬性值。

下列範例會 SectionInformation 取得物件。

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

// Get the section.
UrlsSection section =
    (UrlsSection)config.GetSection("MyUrls");

SectionInformation sInfo =
    section.SectionInformation;
' Get the current configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)

' Get the section.
Dim section As UrlsSection = _
CType(config.GetSection("MyUrls"), UrlsSection)
        
Dim sInfo As SectionInformation = _
section.SectionInformation

下列範例會取得 IsLocked 值。

bool locked =
   sInfo.IsLocked;
Console.WriteLine("Section locked?: {0}",
    locked.ToString());
Dim locked As Boolean = _
sInfo.IsLocked
Console.WriteLine("Section locked?: {0}", _
locked.ToString())

備註

當 或 屬性鎖定AllowOverride相關區段時,屬性IsLocked會傳回 trueAllowDefinition 如果區段無法覆寫或定義於目前的組態檔中,則區段會遭到鎖定。

適用於