|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Sep 2004
Messaggi: 3967
|
[C#]IEnumerable, elementi e conteggio
Ciao a tutti
Ho una classe dove: Codice:
public enum DamageStatus { red, orange, gray, black };
public IEnumerable GetDamageStatusAsEnumerable()
{
String[] strEn = Enum.GetNames(typeof(DamageStatus));
return strEn;
}
Codice:
0 = red; 1 = orange; etc... Grazie RaouL.
__________________
Dai wafer di silicio nasce: LoHacker... il primo biscotto Geek
|
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Aug 2003
Città: Barletta (BA)
Messaggi: 939
|
Codice:
var counter = strEn.GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count()); Console.WriteLine(counter["red"]);
__________________
In a world without fences, who needs Gates? Power by: Fedora 8 - Mac OS X 10.4.11 |
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Sep 2004
Messaggi: 3967
|
![]() Provo subito a metterla in pratica !
__________________
Dai wafer di silicio nasce: LoHacker... il primo biscotto Geek
|
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Feb 2003
Città: Stockholm (SE)
Messaggi: 1343
|
Codice:
public IEnumerable<string> GetDamageStatusAsEnumerable()
{
String[] strEn = Enum.GetNames(typeof(DamageStatus));
return strEn;
}
|
|
|
|
|
|
#5 |
|
Senior Member
Iscritto dal: Sep 2004
Messaggi: 3967
|
Prima di tutto grazie sempre per il vostro aiuto !!
Mi sento così frustrato... non riesco a mettere in pratica niente ! Allora, ho provato ad implementare i vostri suggerimenti ma ancora non ho capito come fare per "sommare" le corrispondenze trovate.. nel senso che al massimo sono riuscito ad ottenere che: Codice:
ad es... red, red, red -> 1, 1, 1
__________________
Dai wafer di silicio nasce: LoHacker... il primo biscotto Geek
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 03:19.




















