简体   繁体   English

在System.Drawing中找不到“Point”

[英]Can't find “Point” in System.Drawing

As I know, Point are exist in namespace System.Drawing , but Visual Studio can't find it. 据我所知, Point存在于命名空间System.Drawing中 ,但Visual Studio找不到它。

using System.Drawing;
class Flower
{
    public Point Location { get; private set; }
}

Error: Can't find name of type or namespace "Point" 错误:找不到类型或命名空间的名称“Point”

Edit 1: .Net 4.5.1 编辑1: .Net 4.5.1

Right click in Solution Explorer on your Project's References entry and click on Add Reference... 在Project的References条目上右键单击Solution Explorer,然后单击Add Reference...

上下文菜单

Make sure you're looking under Assemblies --> Framework, then find and check the checkbox for System.Drawing , then click OK. 确保您在Assemblies - > Framework下查找,然后找到并选中System.Drawing的复选框,然后单击OK。

参考

From here, you can use System.Drawing.Point in your code. 从这里,您可以在代码中使用System.Drawing.Point

As others have indicated, you are missing a reference to System.Drawing in your project. 正如其他人所指出的那样,您在项目中缺少对System.Drawing的引用。 The reason this works in some project types and not others is that some project types, specifically Windows Forms projects, will automatically add the reference to System.Drawing for you. 这在某些项目类型而非其他项目类型中起作用的原因是某些项目类型(特别是Windows窗体项目)将自动为您添加对System.Drawing的引用。 While other project types like Console App, Class Library, or WPF Application do not automatically have that reference, so you have to manually add it. 虽然其他项目类型(如控制台应用程序,类库或WPF应用程序)不会自动具有该引用,因此您必须手动添加它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM