与System.Type进行比较的方法有以下几种:
if (typeof(string) == obj.GetType())
{
// 对象是字符串类型
}
if (obj.GetType() is System.Type intType && intType == typeof(int))
{
// 对象是整数类型
}
if (type1.Equals(type2))
{
// 两个System.Type对象表示相同的类型
}
if (obj.GetType().FullName == "System.String")
{
// 对象是System.String类型
}
以上是几种常见的与System.Type进行比较的方法,根据具体的需求选择适合的方法进行比较。
领取专属 10元无门槛券
手把手带您无忧上云