C#C
C#3y ago
Cheetah

How to make string to int

pls help me i needa make a string variable to int variable for my code but i cant figure out how heres my code
using System;
using System.Runtime.InteropServices;

namespace Guessing_game
{
    internal class Program
    {
        static void Main(string[] args)
        {
         Random rnd = new Random();
        int num = rnd.Next();
        Console.WriteLine(num);
        Console.WriteLine("Guess the number");
        Console.ReadLine();
        string Guess = Console.ReadLine();

        int IntGuess = int.Parse(Guess);

            Console.WriteLine(IntGuess);
            if (num == IntGuess) 
            {
                Console.WriteLine("Good job");
            }
        }
    }
}
Was this page helpful?