Enum.GetNames メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim enumType As Type Dim returnValue As String() returnValue = Enum.GetNames(enumType)
- enumType
列挙型。
enumType に含まれている定数の名前の文字列配列。



GetNames の使用方法については、次のコード例を参照してください。
Imports System Public Class GetNamesTest Enum Colors Red Green Blue Yellow End Enum 'Colors Enum Styles Plaid Striped Tartan Corduroy End Enum 'Styles Public Shared Sub Main() Console.WriteLine("The values of the Colors Enum are:") Dim s As String For Each s In [Enum].GetNames(GetType(Colors)) Console.WriteLine(s) Next s Console.WriteLine() Console.WriteLine("The values of the Styles Enum are:") For Each s In [Enum].GetNames(GetType(Styles)) Console.WriteLine(s) Next s End Sub 'Main End Class 'GetNamesTest
using System; public class GetNamesTest { enum Colors { Red, Green, Blue, Yellow }; enum Styles { Plaid, Striped, Tartan, Corduroy }; public static void Main() { Console.WriteLine("The values of the Colors Enum are:"); foreach(string s in Enum.GetNames(typeof(Colors))) Console.WriteLine(s); Console.WriteLine(); Console.WriteLine("The values of the Styles Enum are:"); foreach(string s in Enum.GetNames(typeof(Styles))) Console.WriteLine(s); } }
using namespace System; enum class Colors { Red, Green, Blue, Yellow }; enum class Styles { Plaid, Striped, Tartan, Corduroy }; int main() { Console::WriteLine( "The values of the Colors Enum are:" ); Array^ a = Enum::GetNames( Colors::typeid ); Int32 i = 0; do { Object^ o = a->GetValue( i ); Console::WriteLine( o->ToString() ); } while ( ++i < a->Length ); Console::WriteLine(); Console::WriteLine( "The values of the Styles Enum are:" ); Array^ b = Enum::GetNames( Styles::typeid ); i = 0; do { Object^ o = b->GetValue( i ); Console::WriteLine( o->ToString() ); } while ( ++i < b->Length ); }
import System.*; public class GetNamesTest { enum Colors { red (0), green (1), blue (2), yellow (3); } //Colors enum Styles { plaid (0), striped (1), tartan (2), corduroy (3); } //Styles public static void main(String[] args) { Console.WriteLine("The values of the Colors Enum are:"); String s[] = Enum.GetNames(Colors.class.ToType()); for (int iCtr = 0; iCtr < s.length; iCtr++) { Console.WriteLine(s[iCtr]); } Console.WriteLine(); Console.WriteLine("The values of the Styles Enum are:"); String s1[] = Enum.GetNames(Styles.class.ToType()); for (int iCtr = 0; iCtr < s.length; iCtr++) { Console.WriteLine(s1[iCtr]); } } //main } //GetNamesTest
import System; public class GetNamesTest { enum Colors { Red, Green, Blue, Yellow }; enum Styles { Plaid, Striped, Tartan, Corduroy }; public static function Main() { Console.WriteLine("The values of the Colors Enum are:"); for(var i : int in Enum.GetNames(Colors)) Console.WriteLine(Enum.GetNames(Colors).GetValue(i)); Console.WriteLine(); Console.WriteLine("The values of the Styles Enum are:"); for(var j : int in Enum.GetNames(Styles)) Console.WriteLine(Enum.GetNames(Styles).GetValue(j)); } }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Enum.GetNames メソッドのページへのリンク