C# 位图可以';你不能归还吗?

C# 位图可以';你不能归还吗?,c#,import,C#,Import,我是C#的新手。然而,这似乎是一个微不足道的问题,但我无法找到答案 我试图简单地返回一个Bitmap对象(通过接口定义),但它无法“找到”Bitmap类。我已经导入了相应的名称空间System.Drawing但我仍然得到同样的错误 找不到类型或命名空间引用(是否缺少程序集引用? 代码如下: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threa

我是C#的新手。然而,这似乎是一个微不足道的问题,但我无法找到答案

我试图简单地返回一个
Bitmap
对象(通过接口定义),但它无法“找到”
Bitmap
类。我已经导入了相应的名称空间
System.Drawing但我仍然得到同样的错误

找不到类型或命名空间引用(是否缺少程序集引用?

代码如下:

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

namespace ConsoleApplication1
{
public interface PlanetInterface
  {
    bool isColonized();
    bool isDestroyed();

    Bitmap getImage();  //Why does Bitmap not 'exist'.



  }
}

非常感谢您的帮助。谢谢。

您需要添加对
系统的引用。绘图
在控制台应用程序中默认情况下不引用它:


IIRC,你需要引用
System.Drawing.dll
System.Drawing.Common.dll
-我记不起默认情况下它们是否在那里(考虑到你的错误,可能不在)。仍然说
Common
dll
在名称空间中不存在我的
使用System.Drawing
不能做到这一点吗?不,您可以从被引用的dll导入名称空间。您必须导入它,但还需要引用它。在winforms应用程序中,虽然它没有被导入,但它是被引用的,这就是为什么只导入它就足够了。谢谢@Ashkan Mobayen Khiabani