[英]Can't create new pen in a new class I created
I just made a new class, but I can't seem to create a new Pen or Graphics or whatever... I openend a new project, and added a new class. 我刚刚开设了一个新班,但似乎无法创建一个新的Pen或Graphics或其他任何东西...我开放了一个新项目,并添加了一个新班。 So when I try to type:
所以当我尝试键入:
Pen mypen = new Pen(Color.Black);
There's an error saying: 有一个错误说:
"The type or namespace name 'Pen' could not be found (are you missing a using directive or an assembly reference?)"
“找不到类型或名称空间名称'Pen'(您是否缺少using指令或程序集引用?)”
So what should I do now? 那我现在该怎么办?
You have to add System.Drawing.dll as a reference, then add a using
directive at the top of the .cs file: 您必须添加System.Drawing.dll作为参考,然后在.cs文件顶部添加
using
指令:
using System.Drawing;
That should fix your problem! 那应该解决您的问题!
You need to add a using directive at the top of your file: 您需要在文件顶部添加using指令:
using System.Drawing;
Also, within the IDE, if you click on the Pen type that has the error, you will see a blue rectangle below it, hover your mouse over that and you will get a menu that gives you options to automatically do that: 另外,在IDE中,如果您单击出现错误的Pen类型,您将在其下看到一个蓝色矩形,将鼠标悬停在该矩形上,您将获得一个菜单,为您提供自动执行此操作的选项:
You can also bring up this binding menu using Shift + Alt + F10 您也可以使用Shift + Alt + F10调出此绑定菜单
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.