C#自定义命名空间的引用问题

来源:百度知道 编辑:UC知道 时间:2024/05/26 06:56:11
在Father文件平中有TestFather类文件和Son文件夹,TestFather代码如下:
using System;
using System.Collections.Generic;
using System.Text;
using Father.Son;
namespace Father
{
class TestFather
{
static void Main(string[] args)
{
TestSon ts = new TestSon();
c.show();
}
}
}
在Father文件夹下的Son文件夹下有TestSon类文件,代码如下:
using System;
using System.Collections.Generic;
using System.Text;
namespace Father.Son
{
class TestSon
{
public void show()
{
Console.WriteLine("Hello China");
}
}
}
用命令提示符编译,为什么引用了命名空间还是提示:
命名空间"Father"中不存在类型或命名空间名称"Son"(是缺少程序集引用吗?)
请问是什么原因?代码是用记事本写的,但是如果利用VS工具创建解决方案则可以调用TestSon类。我学习JAVA的时候好像用记事本就可以引用,为什么C#中不可以?
记事本中怎么添加引用?不是引入命名空间就可以了吗?
using Father.Son;

在你的解决方案资源管理器里边有一个引用>>>右键>>>添加引用
把它添加进去,,java倒的是包(文件夹)C#
倒的是命名空间(类似于虚拟的)

引用添加了吗?
只写 using 是不行的, 还要在 引用里 加入那个 DLL 文件

生成FATHER成DLL文件,然后再添加引用-项目-选择,添加成功!