I'm trying to code in a Portable Class Library
using ASP.NET Core 1.0
, the following instruction:
public static void WriteMessage<T>(T value)
{
if (typeof(T).IsEnum)
{
Debug.Print("Is enum")
}
else
{
Debug.Print("Not Is enum")
}
}
But this code does not compile because the compiler says that the property IsEnum
is non present on Type.
Any suggestions?
Type
中的某些功能已移至.NET Core中的TypeInfo
。
typeof(T).GetTypeInfo().IsEnum
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.