C# Enum ToObject(Type, UInt16)
Description
Enum ToObject(Type, UInt16)
converts the specified
16-bit unsigned integer value to an enumeration member.
Syntax
Enum.ToObject(Type, UInt16)
has the following syntax.
[ComVisibleAttribute(true)]// w ww. j a v a2s . c o m
[CLSCompliantAttribute(false)]
public static Object ToObject(
Type enumType,
ushort value
)
Parameters
Enum.ToObject(Type, UInt16)
has the following parameters.
enumType
- The enumeration type to return.value
- The value to convert to an enumeration member.
Returns
Enum.ToObject(Type, UInt16)
method returns An instance of the enumeration set to value.
Example
/*w w w . j a va2s .c o m*/
using System;
enum Mammals { Cat, Dog, Horse, Dolphin };
public class MainClass{
public static void Main(String[] argv){
Object obj = Enum.ToObject(Mammals.Cat.GetType(),0);
Console.WriteLine(obj);
}
}
The code above generates the following result.