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();
}
}
}
您的項目是否有對「System.Drawing.dll」的引用?這基本上就是*錯誤信息的內容。 – 2013-04-08 02:29:26
如何添加對System.Drawing.dll的引用?我是否需要下載dll或如何在我的機器中找到它並將其指向編譯器? – user1050619 2013-04-08 02:39:00
在你的VS中,顯示Solution Explorer->右鍵單擊References-> Add references-> .NET-> whatever – 2013-04-08 02:40:05