do more with less

KeyValuePair(Of TKey, TValue): un generic che può tornare utile

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)

Technorati tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Comments

Friday, November 24, 2006 - 2:04 AM

ok

???

Add comment


 

  Country flag





Live preview

Friday, December 05, 2008 - 9:36 AM