Condividi tramite


PagesSection.Namespaces Proprietà

Definizione

Ottiene una raccolta di oggetti NamespaceInfo.

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

Valore della proprietà

NamespaceCollection

NamespaceCollection di oggetti NamespaceInfo.

Attributi

Esempio

Nell'esempio di codice riportato di seguito viene illustrato come utilizzare la proprietà Namespaces.

       // 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

Commenti

Gli TagPrefixInfo oggetti corrispondono alla @ Import direttiva in una pagina ASP.NET. La Import direttiva consente di specificare gli spazi dei nomi importati automaticamente in tutte le pagine di un'applicazione.

Si applica a

Vedi anche