On this page:
Ice.Optional type provides constructors and conversion operators that allow you to initialize an instance using the element type or an existing optional value. The default constructor initializes an instance to an unset condition. The
Value property and conversion operator retrieve the current value held by the instance, or throw
System.InvalidOperationException if no value is currently set. Use the
HasValue property to test whether the instance has a value prior to accessing it.
The implicit conversion operators allow you to initialize an
Optional instance without a cast. However, the conversion operator that extracts the current value is declared as
explicit and therefore requires a cast:
This operator raises an exception if no value is set, so the proper way to write this is shown below:
Ice.Optional type provides a constructor and conversion operator that accept
NoneType. Ice defines an instance of this type,
Ice.Util.None, that you can use to initialize (or reset) an
Optional instance to an unset condition:
You can pass
Ice.Util.None anywhere an
Ice.Optional value is expected.