7

我是 C# 的新手,并试图从教程中运行示例 C# 程序。

当我尝试运行以下代码时,出现以下错误:

错误 1 ​​命名空间“System.Drawing”中不存在类型或命名空间名称“Point”(您是否缺少程序集引用?) C:\Users\Documents\Visual Studio 2012\Projects\HelloWorld\HelloWorld\Class1.cs 20 28 你好世界

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace HelloWorld
{
    class Hello
    {
        static void Main()
        {
            Nullable<bool> b = false;
            if (b.HasValue) Console.WriteLine("b is {0}", b.Value);
            else Console.WriteLine("b is not set");

            System.Drawing.Point p = new System.Drawing.Point(20, 30);

            Console.WriteLine(b);
            Console.WriteLine("Hello World");
            Console.WriteLine("Press any key to exit");

            Console.ReadKey();
        }
    }
}
4

1 回答 1

6

在您的解决方案资源管理器中右键单击 References 单击 Add Reference 单击 .NET 选项卡并滚动到System.Drawing. 它应该工作。

于 2014-09-03T11:36:01.317 回答