Struct NullableBool

NullableBool structure

A class for boolean values with possibility to check whether the value was defined or not.

public struct NullableBool : IEquatable<NullableBool>

Constructors

NameDescription
NullableBool(bool)Initializes a new instance of the NullableBool struct with the specified boolean value.
NullableBool(bool, bool)Initializes a new instance of the NullableBool struct.

Properties

NameDescription
IsDefined { get; }Gets a value indicating whether the value was defined; otherwise, false.
Value { get; set; }Gets or sets a value indicating whether current value is true or false.

Methods

NameDescription
Equals(NullableBool)Returns a flag indicating whether this instance is equal to the specified instance of the NullableBool class.
override Equals(object)Returns a flag indicating whether this instance is equal to the specified object.
override GetHashCode()Returns a hash code value for the instance of the NullableBool class.
override ToString()Returns a string that represents the current object.
operator ==Returns a value indicating whether this instance is equal to a specified object.
implicit operatorImplicitly converts a NullableBool instance to a boolean value. Returns true when Value is true and IsDefined is true. (2 operators)
operator !=Returns a value indicating whether this instance is not equal to a specified object.

Examples

Shows how to work with <see cref=“NullableBool” /> class.

var project = new Project();

// lets check where the <see cref="Aspose.Tasks.NullableBool" /> class is used
// the main advantage of <see cref="Aspose.Tasks.NullableBool" /> that 
// one can set it as undefined through constructing
var actualsInSync = new NullableBool(false, false);
Console.WriteLine("'ActualsInSync' Value: " + actualsInSync.Value);
Console.WriteLine("'ActualsInSync' Is Defined: " + actualsInSync.IsDefined);

// ...
// use nullable bool instance
project.Set(Prj.ActualsInSync, actualsInSync);

// ...
var honorConstraints = new NullableBool(true);
Console.WriteLine("'HonorConstraints' ToString: " + honorConstraints.ToString());

// ...
// use nullable bool instance
project.Set(Prj.HonorConstraints, honorConstraints);

// ...

See Also