ElementInformation.LineNumber 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得在組態檔中定義關聯 ConfigurationElement 物件的行號。
public:
property int LineNumber { int get(); };
public int LineNumber { get; }
member this.LineNumber : int
Public ReadOnly Property LineNumber As Integer
屬性值
在組態檔中定義關聯 ConfigurationElement 物件的行號。
範例
下列範例將示範如何使用 LineNumber 屬性。
static public void GetElementLineNumber()
{
// Get the current configuration file.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
// Get the section.
UrlsSection section =
(UrlsSection)config.GetSection("MyUrls");
// Get the collection element.
UrlsCollection urls = section.Urls;
int ln =
urls.ElementInformation.LineNumber;
Console.WriteLine("Urls element line number: {0}",
ln.ToString());
}
Public Shared Sub GetElementLineNumber()
' 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)
' Get the collection element.
Dim urls As UrlsCollection = _
section.Urls
Dim ln As Integer = _
urls.ElementInformation.LineNumber
Console.WriteLine("Urls element line number: {0}", _
ln.ToString())
End Sub