This question already has an answer here:
- `Type.GetProperties` property order 5 answers
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
}
}
My question is, without the OrderBy
in the for loop am I guarenteed that the native order of the List will be the order the properties are declared in the object
Aucun commentaire:
Enregistrer un commentaire