-3

Hello im trying to call a method in a different class so when the user selects the button 1 it will call the

It says no overload for method myMethod takes 0 arguments

using System;

namespace crap
{
    class firstClass
    {
        public static void Main (string[] args)
        {
                int choice = 0;
                while (choice != 1 || choice != 2) {
                Console.WriteLine ("Press 1 for choice 1 or 2 for choice for choice 2");
                choice = Convert.ToInt32 (Console.ReadLine ());

                if (choice == 1) {
                    crap.secondClass.myMethod();
                }
                if (choice == 2) {

                }

            }
        }
    }

    public class secondClass{

        public static void myMethod(int later, int later2)
        {
            Console.WriteLine("You chose option 1");

        }
    }
}
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • 3
    `myMethod` takes two integer parameters. You need to pass them in. Also your loop is incorrect. 1!=2 and 2!=1 so even if someone entered a valid number (2 or 1) it will keep looping. You want `&&` instead of `||` – pinkfloydx33 Nov 24 '17 at 23:54

1 Answers1

-1

using System;

namespace crap { class firstClass { public static void Main (string[] args) { int choice = 0;

        while (choice != 1 && choice != 2)

            {

            Console.WriteLine ("Press 1 for choice 1 or 2 for choice for choice 2");
            choice = Convert.ToInt32 (Console.ReadLine ());

            if (choice == 1) {
                crap.secondClass.myMethod();
            }
            if (choice == 2) {

            }

        }
    }
}

public class secondClass{

    public static void myMethod()
    {

        Console.WriteLine("You chose option 1");

    }
}

}