简体   繁体   中英

Non-null variable evaluating as null

I have a variable with a value; however, it is evaluated as being null

在此处输入图片说明

I suspect it may be because the variable was initialized with:

 FormatterServices.GetUninitializedObject(type);

If this is the case, is there a way to get the object into a good state? Maybe though reflection?

I suspect that EntitySlot (or a base class of EntitySlot ) is overriding Equals which is incorrectly marking the entitySlot instance and null as equal. You can test this out by comparing the result of .Equals() and .ReferenceEquals() .

It is not null - you can clearly see the properties initialized.

But your equality check is showing null - please check your Equals method overload as Cameron has mentioned.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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