Announcements
No record found.
Hello,
I have one Boolean property in C# class (Model). and I want to check if it is NULL or not in X++ code. How can I do this ?
I tried in x++ like : classObject.property != NULL but it gives exception.
How to check for for in X++ for C# boolean type.
Hi Pratik Rami,
Could you, please, share exception details?
Do you know if the boolean property in the C# class is nullable (bool?) or not (bool)? It could be not nullable and therefore you need to compare it with false.
It's a pity that you didn't mention what exception you got.
But if the type is boolean, comparing it with null indeed wrong. Simply use if (classObject.property), or compare it with true or false literals or a boolean expression.
Yes. It is nullable (bool?). Right now I have changed some implementation and not able to Reproduce the exception I got. But yes it is working properly by comparing with false and also working if I write if(classObject.property) as Martin suggested below.
Thanks for the reply
bool and bool? are actually very different things. Therefore you weren't right when saying that it's a Boolean property.
Try something like this in X .
System.Nullable nullableBool = classObject.Property; if (nullableBool.HasValue) { boolean value = nullableBool; } // Or simpler if (classObject.Property.HasValue) { boolean value = nullableBool; }
Let us know how it went; CLR Interop often struggles with more complicated cases and you can't be sure it work until you actually try it.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Giorgio Bonacorsi 722
André Arnaud de Cal... 605 Super User 2026 Season 1
Subra 547