我真的不知道为什么在此处尝试验证属性代码中的输入值时出现此错误:
using ConsoleApplication4.Interfaces;
public struct Vector:IComparable
{
private Point startingPoint;
private Point endPoint;
public Point StartingPoint
{
get
{
return new Point(startingPoint);
}
set
{
if(value != null)
this.startingPoint = value;
}
}
public Point EndingPoint
{
get
{
return new Point(this.endPoint);
}
set
{
if(value != null)
this.startingPoint = value;
}
}
我得到的错误是在我有 if(value!=null)
请您参考如下方法:
struct是一个值类型 - 它不能像 class 那样为“null”可能。您可以使用 Nullable<Point> (或 Point? ),但是。
