Ho bisogno di un modo per creare un IOrderedEnumerable vuota e IEnumerable>Come creare un vuoto IOrderedEnumerable <DynamicNode> e IEnumerable <IGrouping <string, DynamicNode >>
// sopra IGrouping DynamicNode ottiene spogliato da StackOverflow :(
Motivo: creo 3 tipi di liste vuote (IOrdered, IGrouping, IEnumerable) quindi in base ad altre informazioni (opzioni specificate dall'utente come ordine per data di creazione o gruppo per mese) Quindi chiamo una funzione assegnandole un elenco di detto tipo
(snippet breve)
//DOESNT WORK THIS IS THE PART I NEED
IEnumerable<DynamicNode> baseList = Enumerable.Empty<DynamicNode>();
IOrderedEnumerable<DynamicNode> orderedList = (IOrderedEnumerable<DynamicNode>)Enumerable.Empty<DynamicNode>();
IEnumerable<IGrouping<string, DynamicNode>> groupedList = (IEnumerable<IGrouping<string, DynamicNode>>)Enumerable.Empty<DynamicNode>();
//ABOVE DOESNT WORK THIS IS THE PART I NEED
if (order)
{
if (group)
{
groupedList = returnGroupedOrderedList(nodeList, ascending, useFeatured, groupBy, orderBy);
}
else
{
orderedList = returnOrderedList(nodeList, ascending, useFeatured, orderBy);
}
}
Qualcuno sa come farlo?
PS Se non sono stato abbastanza chiaro per favore fatemi sapere come posso aiutare, aiutatemi :)
Grazie!
Perché creare prima le istanze? Perché non solo dichiarare le variabili? 'IOrderedEnumerable orderedList;'. Sembra che tu lo stia nuovamente impostando ancora più in basso. –