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

<ComVisibleAttribute(True)> _ Public Shared Function GetName ( _ enumType As Type, _ value As Object _ ) As String
Dim enumType As Type Dim value As Object Dim returnValue As String returnValue = Enum.GetName(enumType, value)
/** @attribute ComVisibleAttribute(true) */ public static String GetName ( Type enumType, Object value )
ComVisibleAttribute(true) public static function GetName ( enumType : Type, value : Object ) : String
- enumType
列挙型。
値が value である enumType 内にある列挙型定数の名前が含まれた文字列。そのような定数が見つからない場合は、null 参照 (Visual Basic では Nothing)。


GetName の使用方法については、次のコード例を参照してください。
Imports System Public Class GetNameTest 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 4th value of the Colors Enum is {0}", [Enum].GetName(GetType(Colors), 3)) Console.WriteLine("The 4th value of the Styles Enum is {0}", [Enum].GetName(GetType(Styles), 3)) End Sub 'Main End Class 'GetNameTest
using System; public class GetNameTest { enum Colors { Red, Green, Blue, Yellow }; enum Styles { Plaid, Striped, Tartan, Corduroy }; public static void Main() { Console.WriteLine("The 4th value of the Colors Enum is {0}", Enum.GetName(typeof(Colors), 3)); Console.WriteLine("The 4th value of the Styles Enum is {0}", Enum.GetName(typeof(Styles), 3)); } }
using namespace System; enum class Colors { Red, Green, Blue, Yellow }; enum class Styles { Plaid, Striped, Tartan, Corduroy }; int main() { Console::WriteLine( "The 4th value of the Colors Enum is {0}", Enum::GetName( Colors::typeid, 3 ) ); Console::WriteLine( "The 4th value of the Styles Enum is {0}", Enum::GetName( Styles::typeid, 3 ) ); }
import System.*; public class GetNameTest { 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 4th value of the Colors Enum is {0}", Enum.GetName(Colors.class.ToType(), (Int32)3)); Console.WriteLine("The 4th value of the Styles Enum is {0}", Enum.GetName(Styles.class.ToType(), (Int32)3)); } //main } //GetNameTest
import System; public class GetNameTest { enum Colors { Red, Green, Blue, Yellow }; enum Styles { Plaid, Striped, Tartan, Corduroy }; public static function Main() { Console.WriteLine("The 4th value of the Colors Enum is {0}", Enum.GetName(Colors, 3)); Console.WriteLine("The 4th value of the Styles Enum is {0}", Enum.GetName(Styles, 3)); } }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からEnum.GetName メソッドを検索する場合は、下記のリンクをクリックしてください。

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