NamespaceCollection クラスとは? わかりやすく解説

NamespaceCollection クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

名前空間オブジェクトコレクション格納します。このクラス継承できません。

名前空間: System.Web.Configuration
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public NotInheritable Class
 NamespaceCollection
    Inherits ConfigurationElementCollection
Dim instance As NamespaceCollection
public sealed class NamespaceCollection : ConfigurationElementCollection
public ref class NamespaceCollection sealed
 : public ConfigurationElementCollection
public final class NamespaceCollection extends
 ConfigurationElementCollection
public final class NamespaceCollection extends
 ConfigurationElementCollection
解説解説
使用例使用例

以下は構成ファイルからの抜粋です。NamespaceCollection クラス複数プロパティに対して宣言によって値を指定する方法示してます。

<system.web>
  <pages>
    <namespaces>
      <add namespace="System" />
      <add namespace="System.Collections" />
      <add namespace="System.Collections.Specialized" />
      <add namespace="System.ComponentModel" />
      <add namespace="System.Configuration" />
      <add namespace="System.Web" />
    </namespaces>
  </pages>
</system.web>

NamespaceCollection 型を使用する方法次のコード例示します。このコード例は、PagesSection クラストピック取り上げているコード例一部分です。

' 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
// 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;
継承階層継承階層
System.Object
   System.Configuration.ConfigurationElement
     System.Configuration.ConfigurationElementCollection
      System.Web.Configuration.NamespaceCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からNamespaceCollection クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からNamespaceCollection クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からNamespaceCollection クラス を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「NamespaceCollection クラス」の関連用語

NamespaceCollection クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



NamespaceCollection クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS