jeudi 22 juin 2023

How Would I Call Class1 method to Class 2 So I can Print it out on class 2

I have 2 Class here. One that creates the random number and one that prints out the random number except class 2 cannot retrieve the random number and I'm not sure why, any help?

{
    class Class1
    {
        public static void Main(string[] args)
        {
            Random random = new Random();
            int num = random.Next(33, 126);
            Console.WriteLine(num);
            Console.ReadKey();
        }
    }
    class Class2
    {
        static void Main(string[] args)
        {
                Class1 number = new Class1();
                Console.WriteLine(num);
                Console.ReadKey();
        }
    }
}




I tried creating an object for class1 in class2 but it didn't change anything.



Aucun commentaire:

Enregistrer un commentaire