比如有两个类文件分别为 Person.cs 和 Enum.cs :

using System;
using person;

namespace HelloWorld
{
    class HelloWorld
    {
        static void main(string[] args)
        {
            Console.WriteLine("请输入姓名:");
            string name = Console.ReadLine();
            Console.WriteLine("请输入年龄:");
            int age = int.Parse(Console.ReadLine());    //强转

            Person per = new Person(name, age);
            per.sayHello();
        }
    }
}
using System;

namespace Enum
{
    class Enum
    {
        enum Days { Mon = 1, Tue, Wed, Thu, Fri, Sat, Sun, };
        static void Main(string[] args)
        {
            Days day = Days.Thu;
            int x = (int)Days.Thu;
            Console.WriteLine("day = {0}, x = {1}", day, x);
        }
    }
}

我现在需要启动 HelloWorld.cs 并不启动 Enum.cs ,则:

  1. 将 HelloWorld.cs 文件中的 main 方法的 main 改为 Main;

  2. 将 Enum.cs 文件中的 main 方法的 Main 改为 main;

  3. F5 运行调试,成功。反之重复此步骤。

相关文章:

  • 2021-06-13
  • 2022-01-04
  • 2021-09-19
  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-01
  • 2021-04-22
  • 2022-12-23
  • 2021-05-23
  • 2022-01-13
相关资源
相似解决方案