thanks alot for all of your help everyone.
I have used the last bit of code posted here and it seems to work ok. The only problem I have now is I do not know how to pass the result of password back to a variable in Main() so I can use it, before the value was in the "firstpick" variable, but now it's in the password variable in ReadLineAsPassword(). I need it to go into a variable called firstpick just after the "ReadLineAsPassword()" call in Main. Just incase you don't know what I mean, heres my source code:
using System;using System.Collections.Generic;using System.Text;namespace GuessNumber{ class Program { static string ReadLineAsPassword() { string password = ""; while (true) { ConsoleKeyInfo key_info = Console.ReadKey(true); if (key_info.Key == ConsoleKey.Enter) { Console.WriteLine(); return password; } Console.Write('*'); password += key_info.KeyChar; } } static void Main(string[] args) { Console.WriteLine(" -------------------------------"); Console.WriteLine(" | WELCOME TO GUESS NUMBER |"); Console.WriteLine(" -------------------------------"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Please select game type:\n\nType S for singleplayer or M for multiplayer"); string sm = Console.ReadLine(); sm = sm.ToUpper(); while (sm != "S" && sm != "M") { Console.WriteLine(); Console.WriteLine("Invalid choice\n\nType S for singleplayer or M for multiplayer"); sm = Console.ReadLine(); sm = sm.ToUpper(); } if (sm == "M") { MP(); } if (sm == "S") { SP(); } } static void SP() { Console.WriteLine("TO DO SP"); } static void MP() { Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Multiplayer chosen"); Console.WriteLine(); Console.Write("Player 1 please enter your name: "); string p1 = Console.ReadLine(); Console.WriteLine(); Console.Write("Player 2 please enter your name: "); string p2 = Console.ReadLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Game will consist of 4 rounds"); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(p1 + " will guess first"); Console.WriteLine(); Console.Write(p2 + " please pick a number 1 to 10: "); ReadLineAsPassword(); while (firstpick < 1 || firstpick > 10) { Console.WriteLine(); Console.WriteLine("Invalid choice\n\n"); Console.Write(p2 + " please pick a number 1 to 10: "); ReadLineAsPassword(); } Console.WriteLine(); Console.WriteLine(p2 + " has picked."); Console.WriteLine(); Console.Write(p1 + " please enter a guess 1 to 10: "); string firstguessstring = Console.ReadLine(); int firstguess = int.Parse(firstguessstring); while (firstguess < 1 || firstguess > 10) { Console.WriteLine(); Console.WriteLine("Invalid choice\n\n"); Console.Write(p1 + " please enter a guess 1 to 10: "); firstguessstring = Console.ReadLine(); firstguess = int.Parse(firstguessstring); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Results for round 1:"); Console.WriteLine(); Console.WriteLine(p2 + " picked " + firstpick); Console.WriteLine(); Console.WriteLine(p1 + " guessed " + firstguess); Console.WriteLine(); if (firstpick == firstguess) { Console.WriteLine(p1 + " wins round 1!"); } else { Console.WriteLine(p2 + " wins round 1!"); } } } }