How to write a custom PARSE?

zhaozj2021-02-16  59

For example: public enum myenum {monday, tuesday, wensday};

Want to implement: myenum e1 = myenum.parse ("tuesday"); what to do?

When you start Myenum in vs.net IDE, there is no PARSE in the code prompt, I don't think that ENUM doesn't have a PARSE method. But I saw that there is PARSE in the interface of Ienumeric, I don't know.

Later, Saucer came out, wrote a spike: usemyenum e1 = (myenum) System.enum.Parse (Tyenum), "Tuesday";

solved.

However, the custom problem is still not solved, for example, to achieve myenum e1 = myenum.parse ("Tuesday"), this will not work, continue thinking ....

转载请注明原文地址:https://www.9cbs.com/read-19025.html

New Post(0)