【发布时间】:2016-02-18 20:41:06
【问题描述】:
private string DoStuff(object result, StringBuilder returnBuilder)
{
// get a list of all public properties and order by name
// so we can guarentee that the order of the headers and
// the results are the same
foreach (var prop in result.GetType().GetProperties().OrderBy(x => x.Name))
{
// do something cool
}
}
我的问题是,如果在 for 循环中没有 OrderBy,我是否保证 List 的本机顺序将是属性在对象中声明的顺序
【问题讨论】:
-
请问你为什么关心?
标签: c# linq reflection