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

前端 未结 2 1159
不知归路
不知归路 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: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();
    }
    

提交回复
热议问题