被C#2005 Express 撞了一下腰

今天总算逮着一个时间,把VS 2005 Express装上了。急匆匆上马,写个最简单的hello。
using System;
using System.Collections.Generic;
using System.Text;

namespace Console
{
    
class Program
    
{
        
static void Main(string[] args)
        
{
            Console.WriteLine(
"Hello");
        }

    }


}
懒得手动编译了,直接F5运行,出错!!!
编译看看出了什么问题:
 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会影响到编译

posted on 2004-07-26 21:32  Meyer  阅读(1554)  评论(6编辑  收藏  举报

导航