0

I'm very new to programming and am trying to get started on a project. I'm trying to just start out creating a method used in a menu and I can' get it to work. I get error messages CS1525 unexpected symbol for line 5: 'public', line 5: '( 'and line 19 '}'. As well as error cs1547 Keyword void cannot be used this way for line 5. This is all I currently have just to try and figure out what's wrong:

using System;

class MainClass {
  public static void Main (string[] args) {
    public void ramdomMenu() {
      Console.WriteLine("Menu");
      Console.WriteLine("***********");
      Console.WriteLine("A. Selection A");
      Console.WriteLine("B. Selection B");
      Console.WriteLine("C. Selection C");
      Console.WriteLine("D. Selection D");
      Console.WriteLine();
      Console.WriteLine("Make your choice: ");

      // Choice from method menu choice
      menuChoice(Convert.ToChar(Console.ReadLine()));
    }
  }
}

Would really appriciate any and all help!

/G

Glass
  • 1
  • 1
  • Welcome to SO @Glass! The error is telling you exactly what's wrong. Your `randomMenu` method declaration should be moved out of `Main` (I think you could make is `static`, that should work but bad practice: https://stackoverflow.com/a/8135090/5186384) – harveyAJ Mar 22 '21 at 11:14

1 Answers1

1

It seems that you declared a method ramdomMenu() within the static method Main().

Try it like this:

using System;

class MainClass {
  public static void Main (string[] args) {
      Console.WriteLine("Menu");
      Console.WriteLine("***********");
      Console.WriteLine("A. Selection A");
      Console.WriteLine("B. Selection B");
      Console.WriteLine("C. Selection C");
      Console.WriteLine("D. Selection D");
      Console.WriteLine();
      Console.WriteLine("Make your choice: ");

      // Choice from method menu choice
      menuChoice(Convert.ToChar(Console.ReadLine()));
  }
}
RedCrusaderJr
  • 350
  • 1
  • 12