小编sti*_*red的帖子

如何使用反射在派生类的属性之前获取基类的属性

public class BaseDto
{
    public int ID{ get; set; }
}
public class Client: BaseDto
{
     public string Surname { get; set; }
     public string FirstName{ get; set; }
     public string email{ get; set; }    
}

PropertyInfo[] props = typeof(Client).GetProperties();
Run Code Online (Sandbox Code Playgroud)

这将按以下顺序列出属性:姓氏,名字,电子邮件,ID

希望按以下顺序显示属性:ID,姓氏,名字,电子邮件

c# reflection base propertyinfo

5
推荐指数
2
解决办法
2706
查看次数

标签 统计

base ×1

c# ×1

propertyinfo ×1

reflection ×1