Tag: 类型gettype

C#反思:如何获取Nullable 的类型?

我想做的是这样的: switch( myObject.GetType().GetProperty( “id”) ) { case ??: // when Nullable, do this case ??: // when string, do this case ??: // when Nullable, do this object.GetType()下的什么路径将具有我可以使用case语句进行比较的数据类型的字符串名称? 我需要知道类型,所以我可以使用许多Convert.ToInt32(字符串)中的一个,它将使用Reflection设置myObject的值。