次の方法で共有


Enum.ValueOf(Class, String) Method

Definition

Returns the enum constant of the specified enum class with the specified name.

[Android.Runtime.Register("valueOf", "(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;", "")]
[Java.Interop.JavaTypeParameters(new System.String[] { "T extends java.lang.Enum<T>" })]
public static Java.Lang.Object ValueOf (Java.Lang.Class enumClass, string name);
[<Android.Runtime.Register("valueOf", "(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;", "")>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T extends java.lang.Enum<T>" })>]
static member ValueOf : Java.Lang.Class * string -> Java.Lang.Object

Parameters

enumClass
Class

the Class object of the enum class from which to return a constant

name
String

the name of the constant to return

Returns

the enum constant of the specified enum class with the specified name

Attributes

Remarks

Returns the enum constant of the specified enum class with the specified name. The name must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)

Note that for a particular enum class T, the implicitly declared public static T valueOf(String) method on that enum may be used instead of this method to map from a name to the corresponding enum constant. All the constants of an enum class can be obtained by calling the implicit public static T[] values() method of that class.

Added in 1.5.

Java documentation for java.lang.Enum.valueOf(java.lang.Class<T>, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to