如何使用自定义名称空间?

时间:2018-07-05 04:07:05

标签: c# namespaces

这是我的项目树:

.
├── Human.cs
└── main.cs

这是我的main.cs:

using Human;
namespace HelloWorldApplication
{
   class HelloWorld
   {
      static void Main(string[] args)
      { 
         Human.Man.sayHi();
      }
   }
}

这是我的Human.cs:

using System;
namespace Human
{
    class Man{
        public static void sayHi(){
            Console.WriteLine("man is saying 'hi'");
        }
    }
}

我想在main.cs中使用Human。我发现的MSDN文档没有显示如何导入自定义名称空间。

当我尝试编译main.cs时,它抛出main.cs(2,7): error CS0246: The type or namespace name Human'。您是否缺少装配参考?

0 个答案:

没有答案