I'm really new to C#, I started with Javascript so it's a bit of a struggle to understand the behaviour of C#.
I am trying to create a simple object inside my for loop and then display the assigned value afterwards but there is a scope issue with this, and am unclear on how I can then access it outside of the for loop?
This is my code setup:
public class Player{
public int identity;
public int score;
public Player(int id){
identity = id;
score = 0;
}
}
for (int i = 0; i < max; i++){
Player player = new Player(i);
}
//here i want to access a player and print the information for said player
I don't know how i can access the newly created players outside of the loop, how is this done?