Running another .cs file within the main program.cs file

前端 未结 2 1157
不知归路
不知归路 2021-01-27 16:51

I\'m very new to programming in general so I\'m sure this question is naive.

So, I wrote a simple magic eight ball program and I wanted to move onto an adventure game, b

相关标签:
2条回答
  • 2021-01-27 17:31
    namespace MyApplication
    {
        static class Program
        {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new /*the name of your program*/());
            }
        }
    }
    
    0 讨论(0)
  • 2021-01-27 17:32

    Get a look at classes.

    You will probably want to create a new class file and then add your code something like this:

    namespace MyApplication
    {
        class EightBall
        {
            public static void eightball ()
            {
                // Add your code here
            }
        }
    }
    

    Call it from your Main-function like this:

    if (response == 1)
    {
        EightBall.eightball();
    }
    
    0 讨论(0)
提交回复
热议问题