   C-sharp--just started,Comment On Code?
  I started to learn c# yesterday. Its not bad, but I definitely know the wayI am going about programming this "games", is not  good. The problem I am have is not reading the stream correctly, or should I say efficiently. Anyway, help me improve my program,i.e comment on this code. Note: its fairly simple so I did not comment. Although if some section is query, ask please.using System;namespace GAME{    #region NUMBER GUESSING GAME    public class Number_Guess    {   public static void HiLow()   {  int guessNum = -1;  string gNum;  Random rand = new Random();  int goal = rand.Next(1, 25);  int numOfGuess = 0;  Console.WriteLine("Your object it to guess the random number from 1 to 25\n\n");  do  { Console.WriteLine("What will you guess   :  "); gNum = Console.ReadLine(); guessNum = int.Parse(gNum); if (guessNum == goal) {Console.WriteLine("You guessed correct!\n\n Press a key to continue ...");string x = Console.ReadLine();break; } else if (guessNum > goal) {Console.WriteLine("You guessed too high\n");++numOfGuess; } else {Console.WriteLine("You guessed too low\n\n");++numOfGuess; }  } while (guessNum != goal);   }    }    #endregion    #region TIC-TAC-TOE    public class BOARD_GAME    {   const int GAME_STRT = 0;   const int GAME_OVER = 1;   const int RESET = 2; public static void Tic_Tac_toe()   {  Console.Title = "Tic-Tac-Toe";  //Create a The main GameBoard 3x3  char[] GameBoard = new char[9]  { '1','2','3', '4','5','6', '7','8','9'  };  //Initialize  char P1_ID = 'X';  char Comp_ID = 'O';  int GameState = GAME_STRT;  int choice = -1;    Random rand = new Random();  Console.WriteLine("Would you like to be X or O :  ");  P1_ID = (char)Console.Read();  //Dummy reader  Console.ReadLine();  if (P1_ID == 'O' || P1_ID == 'o' || P1_ID == '0')  { Comp_ID = 'X'; P1_ID = 'O'; }    else P1_ID = 'X';  PrintBrd(GameBoard, -1, P1_ID);  choice = GetInput(choice);   Console.Clear();  do  {  PrintBrd(GameBoard, choice, P1_ID);  //Comp Turn  choice = rand.Next(1, 9); //Check if Valid while (!(ValidMove(P1_ID, Comp_ID, GameBoard, choice)))choice = rand.Next(1, 9); PrintBrd(GameBoard, choice, Comp_ID); //Check winner, if any switch (CheckWinner(GameBoard, P1_ID, Comp_ID)) {case 'P': Console.WriteLine("\nCongrats, You beat the stupid computer\n"); GameState = GAME_OVER; goto case '-';case 'C': Console.WriteLine("\nHahaha, how the Hell did you loose???\n"); GameState = GAME_OVER; goto case '-';case 'D': Console.WriteLine("\nIts a Draw Game!\n\n"); GameState = GAME_OVER; goto case '-';case '-':    char op = 'y';    Console.WriteLine("\nPlaye Again? (y/n) :  ");    op = (char)Console.Read();    if (op == 'y' || op == 'Y')    {   GameState = RESET; break;    }    else GameState = GAME_OVER;    break;default: break; } if (GameState == GAME_STRT) {//Get user Inputchoice = GetInput(choice);//Check for valid movewhile (!(ValidMove(P1_ID, Comp_ID, GameBoard, choice)))    choice = GetInput(choice);PrintBrd(GameBoard, choice, P1_ID);//Check winner, if anyswitch (CheckWinner(GameBoard, P1_ID, Comp_ID)){    case 'P': Console.WriteLine("\n\nCongrats, You beat the stupid computer\n"); GameState = GAME_OVER; goto case '-';    case 'C': Console.WriteLine("\n\nHahaha, how the Hell did you loose???\n"); GameState = GAME_OVER; goto case '-';    case 'D': Console.WriteLine("\n\nIts a Draw Game!\n\n"); GameState = GAME_OVER; goto case '-';    case '-':   char op = 'y';   Console.WriteLine("\nPlaye Again? (y/n) :  ");   op = (char)Console.Read();   if (op == 'y' || op == 'Y')   {  GameState = RESET; break;   }   else GameState = GAME_OVER;   break;    default: break;} } if (GameState == RESET) {GameState = resetFunc(GameBoard, GameState);PrintBrd(GameBoard, -1, Comp_ID);Console.ReadLine();choice = GetInput(choice); }  } while (GameState != GAME_OVER);   }   #region void PrintBrdPrint(char[],int,char) //Prints Board   static public void PrintBrd(char[] Brd, int ElemChoice, char Obj_ID)   {  Console.Clear();  //Check for validity  if ((ElemChoice < 1 || ElemChoice > 9) && ElemChoice != -1)  { Console.WriteLine("INVALID ROW CHOICE! ITS BEGIN IGNORED THIS TIME\n\n"); return;  }  else  { if (ElemChoice != -1)Brd[ElemChoice - 1] = Obj_ID;  }  //Print board  for (int i = 0; i < 9; i += 3)  { if (i != 0 && (i % 3 == 0))Console.WriteLine('\n'); Console.WriteLine("{0}  |  {1}  |  {2}", Brd, Brd, Brd);  }   }   #endregion   #region ValidMove(<span class="cpp-keyword">char</span>,<span class="cpp-keyword">char</span>,<span class="cpp-keyword">char</span>[],<span class="cpp-keyword">int</span>) : Check <span class="cpp-keyword">For</span> Valid Move   <span class="cpp-keyword">public</span> <span class="cpp-keyword">static</span> <span class="cpp-keyword">bool</span> ValidMove(<span class="cpp-keyword">char</span> ID, <span class="cpp-keyword">char</span> ID2, <span class="cpp-keyword">char</span>[] GameBrd, <span class="cpp-keyword">int</span> choice)   {  <span class="cpp-keyword">if</span> (choice &lt; <span class="cpp-number">1</span> || choice &gt; <span class="cpp-number">9</span>)  { Console.WriteLine(<span class="cpp-literal">"\nInvalid Dimension\n"</span>); <span class="cpp-keyword">return</span> <span class="cpp-keyword">false</span>;  }  <span class="cpp-keyword">if</span> (GameBrd[choice - <span class="cpp-number">1</span>] == ID || GameBrd[choice - <span class="cpp-number">1</span>] == ID2)  { Console.WriteLine(<span class="cpp-literal">"\nInvalid Dimension\n"</span>); <span class="cpp-keyword">return</span> <span class="cpp-keyword">false</span>;  }  <span class="cpp-keyword">return</span> <span class="cpp-keyword">true</span>;   }   #endregion   #region GetInput(<span class="cpp-keyword">int</span>) <span class="cpp-comment">// Gets user Input</span>   <span class="cpp-keyword">static</span> <span class="cpp-keyword">public</span> <span class="cpp-keyword">int</span> GetInput(<span class="cpp-keyword">int</span> ch)   {  Console.WriteLine(<span class="cpp-literal">"\n\nWhere do you want to place your Move :  "</span>);  ch = Console.Read();  ch -= '<span class="cpp-number">0</span>';  <span class="cpp-comment">//Dummy read</span>  Console.ReadLine();  <span class="cpp-keyword">return</span> ch;   }   #endregion   #region CheckWinner(<span class="cpp-keyword">char</span> [] GameBrd, <span class="cpp-keyword">char</span> Obj_ID,<span class="cpp-keyword">char</span> Obj2_ID) <span class="cpp-comment">// checks for winner</span>   <span class="cpp-keyword">static</span> <span class="cpp-keyword">public</span> <span class="cpp-keyword">char</span> CheckWinner(<span class="cpp-keyword">char</span>[] Gbrd, <span class="cpp-keyword">char</span> P_ID, <span class="cpp-keyword">char</span> C_ID)   {  <span class="cpp-keyword">char</span> winner = '*';  <span class="cpp-comment">// represent neither   </span>  <span class="cpp-keyword">for</span> (<span class="cpp-keyword">int</span> i = <span class="cpp-number">0</span>; i &lt; <span class="cpp-number">9</span>; i++)  { <span class="cpp-keyword">if</span> (i % <span class="cpp-number">3</span> == <span class="cpp-number">0</span>) <span class="cpp-comment">//check horizontal win</span> {<span class="cpp-keyword">if</span> (Gbrd<span style="font-weight:bold;"> == P_ID &amp;&amp; Gbrd == P_ID &amp;&amp; Gbrd == P_ID){ winner = 'P'; <span class="cpp-keyword">return</span> winner; }<span class="cpp-keyword">else</span> <span class="cpp-keyword">if</span> (Gbrd<span style="font-weight:bold;"> == C_ID &amp;&amp; Gbrd == C_ID &amp;&amp; Gbrd == C_ID){ winner = 'C'; <span class="cpp-keyword">return</span> winner; }  } <span class="cpp-keyword">if</span> (i &lt; <span class="cpp-number">3</span>) <span class="cpp-comment">//check vertical win</span> {<span class="cpp-keyword">if</span> (Gbrd<span style="font-weight:bold;"> == P_ID &amp;&amp; Gbrd == P_ID &amp;&amp; Gbrd == P_ID){ winner = 'P'; <span class="cpp-keyword">return</span> winner; }<span class="cpp-keyword">else</span> <span class="cpp-keyword">if</span> (Gbrd<span style="font-weight:bold;"> == C_ID &amp;&amp; Gbrd == C_ID &amp;&amp; Gbrd == C_ID){ winner = 'C'; <span class="cpp-keyword">return</span> winner; } } <span class="cpp-keyword">if</span> (i == <span class="cpp-number">0</span> ) <span class="cpp-comment">//check diagnol win</span> {<span class="cpp-keyword">if</span> (Gbrd<span style="font-weight:bold;"> == P_ID &amp;&amp; Gbrd == P_ID &amp;&amp; Gbrd == P_ID){ winner = 'P'; <span class="cpp-keyword">return</span> winner; }<span class="cpp-keyword">else</span> <span class="cpp-keyword">if</span> (Gbrd<span style="font-weight:bold;"> == C_ID &amp;&amp; Gbrd == C_ID &amp;&amp; Gbrd == C_ID){ winner = 'C'; <span class="cpp-keyword">return</span> winner; } } <span class="cpp-keyword">else</span> <span class="cpp-keyword">if</span> (i == <span class="cpp-number">2</span>) {<span class="cpp-keyword">if</span> (Gbrd<span style="font-weight:bold;"> == P_ID &amp;&amp; Gbrd == P_ID &amp;&amp; Gbrd == P_ID){ winner = 'P'; <span class="cpp-keyword">return</span> winner; }<span class="cpp-keyword">else</span> <span class="cpp-keyword">if</span> (Gbrd<span style="font-weight:bold;"> == C_ID &amp;&amp; Gbrd == C_ID &amp;&amp; Gbrd == C_ID){ winner = 'C'; <span class="cpp-keyword">return</span> winner; } }  }  <span class="cpp-comment">//Check for draw game</span>  <span class="cpp-keyword">int</span> cnt = <span class="cpp-number">0</span>;  <span class="cpp-keyword">for</span> (<span class="cpp-keyword">int</span> i = <span class="cpp-number">0</span>; i &lt; <span class="cpp-number">9</span>; i++)  { <span class="cpp-keyword">if</span> (Gbrd<span style="font-weight:bold;"> == P_ID || Gbrd<span style="font-weight:bold;"> == C_ID)++cnt; <span class="cpp-keyword">else</span> <span class="cpp-keyword">break</span>;  }  <span class="cpp-keyword">if</span> (cnt == <span class="cpp-number">9</span>)  { winner = 'D';  <span class="cpp-keyword">return</span> winner;  }    <span class="cpp-comment">//no winner if reached</span>  <span class="cpp-keyword">return</span> winner;}   #endregion   #region Reset Game  <span class="cpp-keyword">static</span> <span class="cpp-keyword">int</span> resetFunc(<span class="cpp-keyword">char</span>[] brd,<span class="cpp-keyword">int</span> state)   {  <span class="cpp-keyword">for</span> (<span class="cpp-keyword">char</span> i = '<span class="cpp-number">1</span>'; i &lt;= '<span class="cpp-number">9</span>'; i++) brd[i-'<span class="cpp-number">1</span>'] = i;   <span class="cpp-keyword">return</span> (state = GAME_STRT);   }   #endregion    }    #endregion}<span class="cpp-keyword">class</span> mainProg{    <span class="cpp-keyword">static</span> <span class="cpp-keyword">void</span> Main()    {   <span class="cpp-keyword">char</span> p = 'y';   string whichGame = <span class="cpp-literal">"1"</span>;   <span class="cpp-keyword">do</span>   {  Console.Clear();   Console.WriteLine(<span class="cpp-literal">"Which Game do you want to play : \n"</span>);  Console.WriteLine(<span class="cpp-literal">"1) Number Guessing game\n"</span>);  Console.WriteLine(<span class="cpp-literal">"2) Tic-tac-toe Game\n"</span>);  whichGame = Console.ReadLine();  Console.Clear();  <span class="cpp-keyword">switch</span> (<span class="cpp-keyword">int</span>.Parse(whichGame))  { <span class="cpp-keyword">case</span> <span class="cpp-number">1</span>: GAME.Number_Guess.HiLow(); <span class="cpp-keyword">break</span>; <span class="cpp-keyword">case</span> <span class="cpp-number">2</span>: GAME.BOARD_GAME.Tic_Tac_toe(); <span class="cpp-keyword">break</span>;  }  <span class="cpp-comment">//Dummy read</span>  Console.ReadLine();   } <span class="cpp-keyword">while</span> (p == 'y');    }}</pre></div><!–ENDSCRIPT–> <!–EDIT–><span class=editedby><!–/EDIT–>[Edited by - tnutty on June 7, 2009 10:13:26 AM]<!–EDIT–></span><!–/EDIT–>