Your GenderFrequencies
method is defined as needing a parameter (List<Bird>
), and you don't supply that. You need to supply the parameter:
foreach (GenderFrequency g in GenderFrequency.GenderFrequencies(birds))
where birds
would be a (theoretically) defined List<Bird>
object.
However, I would get the List returned from GenderFrequencies
in a temporary variable and then iterate through that temporary variable, rather than calling GenderFrequencies
each time through the loop. Something like this:
List<GenderFrequency> genderFrequencies = GenderFrequencies.GenderFrequencies(birds);
foreach (GenderFrequency g in genderFrequencies)
{
}
Also, I would make a couple of small changes to your program for readability.
First, change your static GenderFrequencies
method to something like GetGenderFrequencies
. It's more descriptive (in my opinion).
Secondly, the GenderFrequencyPlus1
method could be replaced with a simple Frequency++;
.
So it could look something like this:
foreach (GenderFrequency freq in freqs)
{
if (freq.Gender.Equals(b.Gender, StringComparison.CurrentCultureIgnoreCase))
{
freq.Frequency++;
return;
}
}