C# Reflection.Typeinfo/Reflection.Type没有GetProperties/GetFields方法

C# Reflection.Typeinfo/Reflection.Type没有GetProperties/GetFields方法,c#,windows,reflection,C#,Windows,Reflection,我正在尝试为Windows 8.1和Windows Phone 8.1制作一个Windows通用应用程序 这是我的问题的一个示例类,我使用int类型作为示例,但无论我使用哪个类,错误都存在: using System; using System.Collections.Generic; using System.Reflection; using System.Text; namespace myTtrpgHelper { class testClass { v

我正在尝试为Windows 8.1和Windows Phone 8.1制作一个Windows通用应用程序

这是我的问题的一个示例类,我使用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页面说应该支持它,我使用的是visual studio 2013。

您应该使用
DeclaredFields
属性来获取字段,使用
DeclaredProperties
来获取属性。随着.NET框架的发展,反射API经历了一些成长的痛苦。MSDN信息似乎不准确。简而言之,在.NET for Windows应用商店应用程序中,TypeInfo继承自MemberInfo not Type,因此它不能包含继承的成员
GetFields()
GetProperties()
。虽然Get*和声明的*成员都存在于完整框架中,但对于Windows应用商店应用程序,您必须使用声明的*API。本文详细介绍了.NET Framework不同版本中反射API的差异。

我已经编辑了您的标题。请参阅“”,其中的共识是“不,他们不应该”。