Collections Question (.NET 3.5, C#) -
I'm stuck and need help with me anyway I have a Visual Studio 2008 console program that is a game, every strong Need to log the date, string, boolean and integer. Say user plays 10 rounds, I have 10 in each
I want to store those data in a data structure (in the archive I believe) and then after the game is over, it has ended after presenting a simple console report.
I'm stuck it sounds like a simple thing, but I'm not getting the solution. I think there are many ways to accomplish it, but I am looking for the simplest solution.
Edit: I wanted to simplify the answer, but maybe I Too much simplified I changed the temporary structure below (which is a bad idea, thanks for reminding me), with a class, and also properties.
First of all, create data types to keep information:
Public square RoundInformation {public date time {get; Set; } The name of the public string {get; Set; } Receive Public Boolean DidCheat {}; Set; }}
Then create the list to keep it:
public list & lt; RoundInformation & gt; Round = new list & lt; RoundInformation & gt; ();
Then, for each round, create a value with rounded information data and add it to the list:
round-info information = new round Installation (); Info.Date = DateTime.Now; Info.Name = "Bob"; Info.DidCheat = True; // Bob always cheats rounds. Add (info); To loop through
:
foreach (round round round round) {.. console dump, left as an exercise }
Comments
Post a Comment