作者wa007123456 (大笨羊)
看板C_Sharp
标题[问题] 关於using 跟 namespace
时间Fri Mar 28 17:51:32 2008
我是c#初学者 我有看书 但是我看不太懂
using 跟 namespace
之前有学过c/c++的基础
看过using的说明後
心想 c++ 的using namespace std 可以写成using std吗
因为std 不是存在的函式库?
还有namespace 里面 还可以有namespace
那之间的互通要怎麽用
例如
namespace haha{
class1{
static void Main(){
}
}
namespace hehe{
class{
static int Add(int x,int y){
return(x+y);
}
}
}
那在 static void Main(){}
里面要用Add函式
是不是要先在class1里面写 using hehe;
如果没写
那是不是Main 里面写
hehe.Add(xxx,xxx) 呢?
请问我的观念正确吗?
请高手教我
ps:我买的书(Visual C# 2005 初学指引 作者:陈正凯 )
我刚把第二章读完
}
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 125.228.230.190
1F:推 tomex:正确 03/28 17:58
2F:→ wa007123456:经过测试 using 只能在第一个namespace下面 03/28 18:28
3F:→ wa007123456:而 hehe 里面要写函式 还是要给他加个类别class 03/28 18:28
4F:→ wa007123456:然後 类别里面函式要 静态的 并且宣告public 03/28 18:29
5F:→ wa007123456:c#真是复杂压 03/28 18:29
6F:→ wa007123456:所以用Add 要写成 hehe的类别名字.Add 03/28 18:30
7F:→ wa007123456:为什麽要搞这麽多 命名空间阿 03/28 18:31
8F:推 d8625038:命名空间很重要也很好用...我个人觉得啦 03/29 15:16
9F:推 huge:这排版让我看了一下才发现hehe在haha下 0rz 03/29 19:29