Obtener claves de una búsqueda
¿Cómo obtengo la colección de claves de una búsqueda que creé a través del .Método ToLookup ()?
Tengo una búsqueda que asigna valores int a grupos de instancias de una clase personalizada. Necesito una colección de todas las claves int que contiene la búsqueda. ¿Hay alguna forma de hacer esto, o tengo que recogerlos y guardarlos por separado?
32
2 answers
Puede iterar a través del conjunto de grupos de elementos clave y leer las claves, por ejemplo,
var keys = myLookup.Select(g => g.Key).ToList();
42
Author: Rup,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-04-26 14:27:11
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-04-26 14:27:11
Una forma rápida:
var myKeys = myLookup.Select(l=>l.Key);
8
Author: KeithS,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-04-26 14:30:12
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-04-26 14:30:12