c# - 如何使用自定义命名空间?
问题描述
这是我的项目树:
.
├── 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' 找不到。您是否缺少程序集参考?`
解决方案
推荐阅读
- r - Packages Crashing R after Using OpenBLAS
- sql - 按同一列上的多个值过滤
- stacked-chart - Bars moving out x-axis
- html - issue with CSS minus margin
- bash - While loop in bash executes only once
- android - Status bar height on s8+ in full screen mode
- postgresql - psql can not access Postgres running in a Docker container
- xml - Submitting multipart/related content type with XML using PHP curl
- core-data - Core Data Empty on App update
- django - How can I run Django unit test in Microsoft TFS automatically?