Voting System Using List (C#)

Good morrow to you all.

I’ve been making this card game, and encountered a problem that I myself can’t solve.

So, there is a deck of cards (list of strings, the game doesn’t require anything more complex), and a list of players.

Every player can vote a player once, and in a function I want to calculate how many votes each player gets.

for (int i = 0; i < playerAmount; i++)
{
	if (votedPlayers.Contains(players*))*
  • {*
    _ voteCounts*++;_
    _
    }_
    _
    }*_
    votedPlayers contains a string for what player the voter voted for.
    voteCounts contains an int for how many votes a player gets.
    This really isn’t the proper way to do it since it does not work, so I am asking if the humble community of Unity would know how to help me.
    Best Regards,
    Kirei

Personally I would create a dictionary to store the voting data.

Assuming the following declarations:

List<string> votedPlayers;
Dictionary<string, int> voteCounts;

Then the following should do the trick:

foreach(string player in votedPlayers){
    voteCounts[player] += 1;
}