zoukankan      html  css  js  c++  java
  • C# 在同一个项目里启动不同的类文件

    比如有两个类文件分别为 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 运行调试,成功。反之重复此步骤。

  • 相关阅读:
    struts总结
    struts的MVC详细实现
    struts的由来
    Hibernate的搭建及使用
    Hibernate简介
    泛型
    eclipse手动添加源码
    beanUtils操作bean的属性
    ref:JAVA之Forward和Redirect的区别
    ref:下一个项目为什么要用 SLF4J
  • 原文地址:https://www.cnblogs.com/yjq520/p/6798664.html
Copyright © 2011-2022 走看看