Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
C#
IList<Object> playerlist = new List<Object>();


playerlist.Add(new Player() { Account_Level = "", ChampionName = "", Tier = "", playerName = "", taskForce = "", tierLosses = 0, tierWins = 0 });


I want to see each object in differents Image so I do :

What I have tried:

C#
for (int i = 0; i < playersimages_team_1.Length; i++)
{ 
foreach(Player player in playerlist)
{
SetChampionImg(player,playersimages_team_1[i])//void SetChampionImg(string ChampionName, Image PlayerSelected)
}
}

But this give me only the last Object in every Image :/, my bet is on "continue;" but don't seem to work.
Posted
Updated 16-Oct-18 7:30am
v3

1 solution

C#
for (int i = 0; i < playersimages_team_1.Length; i++)
{ 
  foreach(Player player in playerlist)
  {
    SetChampionImg(player,playersimages_team_1[i]);
  }
}

There is no connection between the inner and outer loop...
The inner loop pushes all the players (one-by-one) to playersimages_team_1[i], overwriting the previous, as i iterates only in the outer loop, after the inner ran out...

Something like this may solve the problem:
C#
int i = 0;
foreach(Player player in playerlist)
{
  SetChampionImg(player,playersimages_team_1[i]);

  i++;
}
 
Share this answer
 
Comments
Kapparina 16-Oct-18 14:04pm    
Thank you Man ! Codeproject are the best.
Kornfeld Eliyahu Peter 16-Oct-18 14:08pm    
You are very welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900