I have defined an enumeration of AttributeName
Then write the following code:
Enum. GetValues (AttributeName);
There is no doubt that it is wrong. People say they want to add a typeof.
That is, enum. GetValues (Typeof (AttributeName));
So here's the question, why use the typeof operator?
Typeof (XX) Returns an object of type XX, Typeof (AttributeName) is an object that returns a AttributeName type.
( refer to link https://msdn.microsoft.com/zh-cn/library/58918ffs)
This means that the AttributeName is not an object, just a name or a attributename type (the same for enumerations)! Is the same for enumerations.
The parameter information for the GetValues () method is shown here:
public static Array GetValues (Type enumtype)
The requirement parameter is
Type Enumtype is an object of enum type! Yes, it's the object, Y.
Handling enumeration-related issues, the typeof operator is really essential!
The first essay, pure personal experience very much hope that the Tongren can refer to the lack of batch leakage, but also hope to hold the problem to the students to help.
The necessity of the C #----Type () method for problems encountered with enumerations