using
System;
using System.Collections.Generic;
using System.Text;
namespace Console
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello");
}
}
}
using System.Collections.Generic;
using System.Text;
namespace Console
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello");
}
}
}
编译看看出了什么问题:
Error 1 The type or namespace name 'WriteLine' does not exist in the namespace 'Console' (are you missing an assembly reference?) C:\Documents and Settings\Administrator\Local Settings\Application Data\Temporary Projects\Console\Program.cs 15 20
晕,怎么回事? 改成
System.Console.WriteLine("Hello");
才勉强通过。
是bug还是C#2.0做了什么改动?或则我这出了什么问题?
modify:
在 JohnnyHu 的提醒下,我发现自己的心是这样的粗。
将namespace修正,namespace HelloWorld还是不能通过编译。后来发现是因为我的工程的根namespace是Console的原因,不过这个现象我认为不应该出现,因为我的所有代码都没有使用Console着个namespace,也就是说最后生成的Assemble里边不会有Console这个namespace,这种情况下报错有点不应该。
明天到2003下看看。
补充:
2003中设置default namespace为Console不会影响编译
在CS2005Express中设置Root namespace为Console会影响到编译