alaskajohn

Graphics I: M Loscocco

Sep 17th, 2013
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. //Use the following dynamic list
  2. List<string> mainMenuWords;
  3.  
  4. //Try this function instead for your data load
  5.  
  6.         private void LoadMainMenuOptions()
  7.         {
  8.             try
  9.             {
  10.                 using (StreamReader sr = new StreamReader("Content/MainMenu.txt"))
  11.                 {
  12.                     string line;
  13.                     while ((line = sr.ReadLine()) != null)
  14.                     {
  15.                         mainMenuWords.Add(line);
  16.                     }
  17.                     sr.Close();
  18.                 }
  19.  
  20.             }
  21.             catch (FileNotFoundException e)
  22.             {
  23.                 Console.WriteLine(String.Concat(e.Message, e.StackTrace));
  24.             }
  25.         }
  26.  
  27. //Then in your game initialization:
  28.  
  29.             mainMenuWords = new List<string>();
  30.             LoadMainMenuOptions();
  31.  
  32.             foreach (string s in mainMenuWords)
  33.                 Console.WriteLine(s);
Advertisement
Add Comment
Please, Sign In to add comment