PagesSection.Namespaces Eigenschaft
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Ruft eine Auflistung von NamespaceInfo-Objekten ab.
public:
property System::Web::Configuration::NamespaceCollection ^ Namespaces { System::Web::Configuration::NamespaceCollection ^ get(); };
[System.Configuration.ConfigurationProperty("namespaces")]
public System.Web.Configuration.NamespaceCollection Namespaces { get; }
[<System.Configuration.ConfigurationProperty("namespaces")>]
member this.Namespaces : System.Web.Configuration.NamespaceCollection
Public ReadOnly Property Namespaces As NamespaceCollection
Eigenschaftswert
Eine NamespaceCollection von NamespaceInfo-Objekten.
- Attribute
Beispiele
Im folgenden Codebeispiel wird die Verwendung der Namespaces-Eigenschaft veranschaulicht.
// Get the AutoImportVBNamespace property.
Console.WriteLine("AutoImportVBNamespace: '{0}'",
pagesSection.Namespaces.AutoImportVBNamespace.ToString());
// Set the AutoImportVBNamespace property.
pagesSection.Namespaces.AutoImportVBNamespace = true;
// Get all current Namespaces in the collection.
for (int i = 0; i < pagesSection.Namespaces.Count; i++)
{
Console.WriteLine(
"Namespaces {0}: '{1}'", i,
pagesSection.Namespaces[i].Namespace);
}
// Create a new NamespaceInfo object.
System.Web.Configuration.NamespaceInfo namespaceInfo =
new System.Web.Configuration.NamespaceInfo("System");
// Set the Namespace property.
namespaceInfo.Namespace = "System.Collections";
// Execute the Add Method.
pagesSection.Namespaces.Add(namespaceInfo);
// Add a NamespaceInfo object using a constructor.
pagesSection.Namespaces.Add(
new System.Web.Configuration.NamespaceInfo(
"System.Collections.Specialized"));
// Execute the RemoveAt method.
pagesSection.Namespaces.RemoveAt(0);
// Execute the Clear method.
pagesSection.Namespaces.Clear();
// Execute the Remove method.
pagesSection.Namespaces.Remove("System.Collections");
// Get the current AutoImportVBNamespace property value.
Console.WriteLine(
"Current AutoImportVBNamespace value: '{0}'",
pagesSection.Namespaces.AutoImportVBNamespace);
// Set the AutoImportVBNamespace property to false.
pagesSection.Namespaces.AutoImportVBNamespace = false;
' Get the AutoImportVBNamespace property.
Console.WriteLine( _
"AutoImportVBNamespace: '{0}'", _
pagesSection.Namespaces.AutoImportVBNamespace)
' Set the AutoImportVBNamespace property.
pagesSection.Namespaces.AutoImportVBNamespace = True
' Get all current Namespaces in the collection.
Dim i As Int16
For i = 0 To pagesSection.Namespaces.Count - 1
Console.WriteLine( _
"Namespaces {0}: '{1}'", i, _
pagesSection.Namespaces(i).Namespace)
Next
' Create a new NamespaceInfo object.
Dim namespaceInfo As System.Web.Configuration.NamespaceInfo = _
New System.Web.Configuration.NamespaceInfo("System")
' Set the Namespace property.
namespaceInfo.Namespace = "System.Collections"
' Execute the Add Method.
pagesSection.Namespaces.Add(namespaceInfo)
' Add a NamespaceInfo object using a constructor.
pagesSection.Namespaces.Add( _
New System.Web.Configuration.NamespaceInfo( _
"System.Collections.Specialized"))
' Execute the RemoveAt method.
pagesSection.Namespaces.RemoveAt(0)
' Execute the Clear method.
pagesSection.Namespaces.Clear()
' Execute the Remove method.
pagesSection.Namespaces.Remove("System.Collections")
' Get the current AutoImportVBNamespace property value.
Console.WriteLine( _
"Current AutoImportVBNamespace value: '{0}'", _
pagesSection.Namespaces.AutoImportVBNamespace)
' Set the AutoImportVBNamespace property to false.
pagesSection.Namespaces.AutoImportVBNamespace = False
Hinweise
Die TagPrefixInfo Objekte entsprechen der @ Import
Direktive auf einer ASP.NET Seite. Mit der Import
Direktive können Sie Namespaces angeben, die automatisch auf alle Seiten einer Anwendung importiert werden.