我有问题。我的代码:
class Program
{
static void Main(string[] args)
{
Point[] points = {
new Point(10, 20),
new Point(100, 200),
new Point(400, 500)
};
Point first = Array.Find(points, pointFind);
Console.WriteLine("Found: {0}, {1}", first.X, first.Y);
Console.Read();
}
private static bool pointFind(Point point)
{
if (point.X % 2 == 0)
{
return true;
}
else
{
return false;
}
}
}
也许这个程序错了,但我不知道为什么我有错误"类型或命名空间名称' Point'找不到(你错过了使用指令或汇编引用吗?"。我有#34;使用System.Drawing"但它对我没用。
答案 0 :(得分:1)
除了using System.Drawing
之外,您还需要引用 System.Drawing.dll
程序集。
如果您的项目是控制台应用程序或WinForms应用程序以外的任何其他应用程序,则在创建新项目时默认情况下不会引用该程序集。
答案 1 :(得分:-2)
您可以将Point更改为System.Drawing.Point或将此行添加到顶部:
using System.Drawing;