Cercando un'alternativa al solito IEnumerator list = items.GetEnumerator() ho trovato questo interessante generic che permette di eseguire un'iterazione tra le coppie di chiave/valore di un Dictionary.L'ho quindi subito usato per passare dal IDictionary ritornato da un metodo della DAL ad un List come evidenziato nel codice seguente:
List resources = new List(); Dictionary<string, object> items = ResourcesSqlDAL.ResourcesCollection(); foreach (KeyValuePair<string, object> item in items) { resources.Add((LocalizedResource)item.Value); } return resources;
Per approfondimenti: KeyValuePair (struttura generica)
Be the first to rate this post
Friday, November 24, 2006 - 2:04 AM
ok
???
Friday, December 05, 2008 - 9:36 AM