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的本机顺序将是在对象中声明属性的顺序