Summary
TryNull method performs a check whether the serialized value is null value, and, if yes, reads (skips) it.
Syntax
function TryNull: Boolean;
Return Value
Returns True if null value has been read (skipped), False is the current value is not a null value.
Remarks
Use TryNull method to check whether the value which is de-serialized is null value. TryNull is a low-level method, which is used by the serialization engine itself when de-serializing object values. So, its perfectly valid to use Value method instead of Null method to de-serialize object values without explicit testing for nulls:
Delphi | Copy Code |
---|---|
obj := D.Value<TMyObject>; if obj = nil then DoSomething else DoSomethingElse(obj); |
Note: |
---|
TryNull return False if current value is not the null value. In this case TryNull does not skip current value and it still need to be read using Value (or some other) method(s). |