ElementInformation.LineNumber Property

 

Gets the line number in the configuration file where the associated ConfigurationElement object is defined.

Namespace:   System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)

public int LineNumber { get; }

Property Value

Type: System.Int32

The line number in the configuration file where the associated ConfigurationElement object is defined.

The following example shows how to use the LineNumber property.

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());

}

.NET Framework
Available since 2.0
Return to top
Show: