locked
TypeName of an enum class

    Question

  • I have a public enum class that I am returning from a property.  To implement ICustomProperty I need to return the TypeName associated with the enum class.  For ref classes I can just use either GetType() or ::typeid.  How would I get this from an enum class?  On the same note, how would I get it for an integer type, say int?
    Wednesday, February 13, 2013 9:54 PM

Answers

  • To get the TypeName I use something like IVector<MyType^>::typeid.  For a public enum class I use MyEnum::typeid.  What was throwing my off is that I get a squiggly under MyEnum: IntelliSense: name followed by '::' must be a class or namespace name.  It still compiles, though.

    I guess that by now I should just be used to ignoring IntelliSense errors in C++/CX.  It seems that a large number of them are wrong.

    • Marked as answer by diltsman Tuesday, February 19, 2013 6:22 PM
    Tuesday, February 19, 2013 6:22 PM

All replies

  • No, It will return "Windows.Foundation.IReference`1<App1.Enum1>”. In this value, you may get “App1.Enum1”.

     

    You can provide us a part of your codes, maybe we can help you to finish it.

     

    Best regards,

    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Jesse Jiang Monday, February 18, 2013 7:11 AM
    • Unproposed as answer by diltsman Tuesday, February 19, 2013 6:18 PM
    Friday, February 15, 2013 2:30 AM
  • To get the TypeName I use something like IVector<MyType^>::typeid.  For a public enum class I use MyEnum::typeid.  What was throwing my off is that I get a squiggly under MyEnum: IntelliSense: name followed by '::' must be a class or namespace name.  It still compiles, though.

    I guess that by now I should just be used to ignoring IntelliSense errors in C++/CX.  It seems that a large number of them are wrong.

    • Marked as answer by diltsman Tuesday, February 19, 2013 6:22 PM
    Tuesday, February 19, 2013 6:22 PM