gpt4 book ai didi

c# - 如何检查结构是否已实例化?

转载 作者:IT王子 更新时间:2023-10-29 04:20:37 25 4
gpt4 key购买 nike

<分区>

我有一个结构(出于这个问题的目的)非常模仿内置的 Point 类型。

我需要在使用它之前检查它是否已经被实例化。当它是 Point 时,我可以这样做:

if (this.p == null)

但是现在会产生以下错误:

Operator '==' cannot be applied to operands of type 'ProportionPoint' and '<null>'

如何将我的结构与 null 进行比较?还有另一种检查实例化的方法吗?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com