我正在尝试制作Windows通用应用程序,用于Windows 8.1和Windows Phone 8.1。Reflection.Typeinfo/Reflection.Type没有GetProperties/GetFields方法
下面是一个例子类,我的问题,我现在用的是int类型为例,但错误是存在的,无论类的使用:
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace myTtrpgHelper
{
class testClass
{
void testMethod()
{
int c = new int();
Type type = c.GetType();
TypeInfo typeInfo = IntrospectionExtensions.GetTypeInfo(type);
PropertyInfo[] p = typeInfo.GetProperties();
PropertyInfo[] p2 = type.getProperties();
PropertyInfo[] p3 = typeInfo.GetFields();
PropertyInfo[] p4 = type.GetFields();
}
}
}
的的GetProperties,和GetFields都显示错误:
'System.Reflection.TypeInfo' does not contain a definition for 'GetFields' and no extension method 'GetFields' accepting a first argument of type 'System.Reflection.TypeInfo' could be found (are you missing a using directive or an assembly reference?)
MSDN的页面http://msdn.microsoft.com/en-us/library/system.reflection.typeinfo.aspx说,它应该得到支持,我使用的Visual Studio 2013年
我编辑了你的标题。请参阅:“[应该在其标题中包含”标签“](http://meta.stackexchange.com/questions/19190/)”,其中的共识是“不,他们不应该”。 –