次の方法で共有


ResourceSet コンストラクタ (String)

ResourceSet クラスの新しいインスタンスを、指定したファイルを開いてリソースを読み取るシステムの既定の ResourceReader を使用して作成します。

名前空間: System.Resources
アセンブリ: mscorlib (mscorlib.dll 内)

構文

'宣言
Public Sub New ( _
    fileName As String _
)
'使用
Dim fileName As String

Dim instance As New ResourceSet(fileName)
public ResourceSet (
    string fileName
)
public:
ResourceSet (
    String^ fileName
)
public ResourceSet (
    String fileName
)
public function ResourceSet (
    fileName : String
)

パラメータ

  • fileName
    読み取るリソース ファイル。

例外

例外の種類 条件

ArgumentNullException

fileName パラメータが null 参照 (Visual Basic では Nothing) です。

使用例

Imports System
Imports System.Resources
Imports System.Collections
Imports Microsoft.VisualBasic

Class EnumerateResources
   
   Public Shared Sub Main()
      ' Create a ResourceSet for the file items.resources.
      Dim rs As New ResourceSet("items.resources")      
      
      ' Create an IDictionaryEnumerator to read the data in the ResourceSet.
      Dim id As IDictionaryEnumerator = rs.GetEnumerator()
      
      ' Iterate through the ResourceSet and display the contents to the console. 
      While id.MoveNext()
         Console.WriteLine(ControlChars.NewLine + "[{0}] " + ControlChars.Tab + "{1}", id.Key, id.Value)
      End While 

      rs.Close()

   End Sub

End Class
using System;
using System.Resources;
using System.Collections;

class EnumerateResources 
{
    public static void Main() 
    {
        // Create a ResourceSet for the file items.resources.
        ResourceSet rs = new ResourceSet("items.resources"); 

        
        // Create an IDictionaryEnumerator to read the data in the ResourceSet.
        IDictionaryEnumerator id = rs.GetEnumerator(); 

        // Iterate through the ResourceSet and display the contents to the console. 
        while(id.MoveNext())
          Console.WriteLine("\n[{0}] \t{1}", id.Key, id.Value); 

        rs.Close();
 
    }
}
using namespace System;
using namespace System::Resources;
using namespace System::Collections;
int main()
{
   
   // Create a ResourceSet for the file items.resources.
   ResourceSet^ rs = gcnew ResourceSet( "items.resources" );
   
   // Create an IDictionaryEnumerator* to read the data in the ResourceSet.
   IDictionaryEnumerator^ id = rs->GetEnumerator();
   
   // Iterate through the ResourceSet and display the contents to the console.
   while ( id->MoveNext() )
      Console::WriteLine( "\n [{0}] \t {1}", id->Key, id->Value );

   rs->Close();
}
import System.*;
import System.Resources.*;
import System.Collections.*;

class EnumerateResources
{

    public static void main(String[] args)
    {
        // Create a ResourceSet for the file items.resources.
        ResourceSet rs = new ResourceSet("items.resources");

        // Create an IDictionaryEnumerator to read the data in the ResourceSet.
        IDictionaryEnumerator id = rs.GetEnumerator();

        // Iterate through the ResourceSet and display the contents to 
        // the console. 
        while (id.MoveNext()) {
            Console.WriteLine("\n[{0}] \t{1}", id.get_Key(), id.get_Value());
        }
        rs.Close();
    } //main 
} //EnumerateResources

プラットフォーム

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。

バージョン情報

.NET Framework

サポート対象 : 2.0、1.1、1.0

.NET Compact Framework

サポート対象 : 2.0、1.0

参照

関連項目

ResourceSet クラス
ResourceSet メンバ
System.Resources 名前空間