VMware {code} Community
Mobster
Contributor
Contributor

Retrieve bool properties in C#

How does one handle bool properties retrieved in .NET C# code?

On the VMware side of the house, the values can be true, false, or unset (null).

bool in C# cannot be null.

Whenever I retrieve properties that are bool, and they happen to be unset, they show up as false in c#.  How can I differentiate in c# code whether the property is really set to false or whether it is just not set?

Thanks in advance for any help,

--Moby

0 Kudos
2 Replies
Mobster
Contributor
Contributor

Found a way around it.  I found other properties that indicate whether the boolean property in question is null or not.  Also found out about SOAP extensions to be able to handle cases where this may not work in the future.

0 Kudos
Steve_Jin
Expert
Expert

check out http://www.doublecloud.org/2010/01/why-does-c-web-service-code-look-weird/ for comprehensive discussion.

steve, author of VMware VI and vSphere SDK

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
0 Kudos