what is the type of the value that enum.parse returns?
function:
enum.parse()
Any one khnow c#?
The method Enum.Parse() (note the capitols) returns an object of type Object in C#.
Here's the definition:
public static Object Parse (Type enumType, string value)
That means you must cast it appropriately.
// Say you have an enum:
enum MyEnum
{
a = 1,
b = 2
}
// Say then that 's' is your input string, which is populated
// elsewhere, then to get the output of Enum.Parse to be
// of the type you want, you have to cast it:
MyEnum myEnum =
(MyEnum)Enum.Parse(
typeof(MyEnum), s);
Reply:enum.parse(System.Type t, String s)
enum.parse(System.Type t, String s, Boolean b)
will read string in the s argument and attemp to match it to one of the enum labels in the collection supplied as t. In the second form, b denotes if the parse will ignore case differences or not.
For examples and details, see msdn.microsoft.com - a free encyclopedia of programming concepts for .NET
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment