2013-04-08 66 views
5

我是C#的新手,并尝试从教程运行示例C#程序。名称空间中不存在点System.Drawing

当我尝试运行下面的代码,我得到了以下错误:

Error 1 The type or namespace name 'Point' does not exist in the namespace 'System.Drawing' (are you missing an assembly reference?) C:\Users\Documents\Visual Studio 2012\Projects\HelloWorld\HelloWorld\Class1.cs 20 28 HelloWorld

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(); 
     } 
    } 
} 
+7

您的项目是否有对“System.Drawing.dll”的引用?这基本上就是*错误信息的内容。 – 2013-04-08 02:29:26

+0

如何添加对System.Drawing.dll的引用?我是否需要下载dll或如何在我的机器中找到它并将其指向编译器? – user1050619 2013-04-08 02:39:00

+5

在你的VS中,显示Solution Explorer->右键单击References-> Add references-> .NET-> whatever – 2013-04-08 02:40:05

回答

2

在您的Solution Explorer中右键点击引用点击添加引用单击.net选项卡上,滚动到System.Drawing 。它应该工作。

相关问题