Hi I'm trying to teach myself C# to make myself more marketable as a programmer. So far all I know is C++.
Anyway, a friend advised me just to start writing simple C# programs and then eventually I'll "know" C#. (You know what I'm talking about)
My first simple program I'm trying to write is a guessing game where the computer thinks of a random number between 1 and 100 and the human tries to guess it. Here's my code so far:
Problem is that when I try to compare a variable of type int to a variable of type Random I get an error. What can I do? Thanks, ~AdamCode:using System; using System.Collections.Generic; using System.Text; namespace Guessing_Game { class Program { static void Main(string[] args) { string guess; Console.WriteLine("Welcome to Adam Henderson's C# Guessing Game!\n"); Console.WriteLine("Guess a number from 1 to 100."); guess = Console.ReadLine(); Random random = new Random(); // C#'s way of giving you a random number random.Next(1, 100); int guess2 = Int32.Parse(guess); if (random < guess2) Console.WriteLine("Oh! You guessed too high! Guess again!"); else if (random > guess2) Console.WriteLine("Oh! You guessed too low! Guess again!"); else { Console.WriteLine("You guessed correct! The answer was {0}!", guess2); } } } }