I have a List<> of type GameResult that I want to populate with a new instance of the class GameResult using data from an array(gamerArray).
So I have this using a foreach loop.
List<GameResult> gameResults = new List<GameResult>();
foreach (var g in gamerArray.GamePlayers)
{
gameResults.Add(
new GameResult
{
GameID = g.GameID,
GameName = g.GameName,
SessionStart = g.StartTime,
SessionEnd = g.EndTime,
SessionMessage = "You Won!"
});
}
Is there a way to use Linq to iterate over the array and create the new List of GameResult objects?
Thanks