C#C
C#4y ago
Redoxi

Why does this not work? [Answered]

Hey, pretty new to coding and trying some things out, someone knows why it says that my var "randomNumber" is not in the context?
using System;

namespace Awesome_Program
{
    class Program
    {
        static void Main(string[] args)
        {
            Typewriter("Hello... Wizard!");
        }

        public static int NumberGen()
        {
            Random numberGen = new Random();
            int number = numberGen.Next(50,300); 
        }

        public static void Typewriter(string word)
        {
           for (int i = 0; i < word.Length; i++)
           {
                Console.Write(word[i]);
                int randomNumber = NumberGen();
                System.Threading.Thread.Sleep(randomNumber);
           } 
        }
    }
}
Was this page helpful?