DefaultableInt32 Struct
Provides a representation for an int that can be defaulted.
[TypeConverter(typeof(DefaultableInt32Converter))]
public readonly struct DefaultableInt32 : IEquatable<DefaultableInt32>
- Implements:
- IEquatable<DefaultableInt32>
Constructors
DefaultableInt32(int)
Initializes an instance of the structure.
public DefaultableInt32(int value)
| Parameter | Type | Description |
|---|---|---|
| value | int | The integer value of the structure. |
Properties
Default
The DefaultableInt32 that represents a default value.
IsDefault
Indicates whether the value of the structure is flagged as a default.
public bool IsDefault { get; }
Property Value
- bool:
trueif the value of the structure is flagged as a default; otherwise,false.
Value
The value of the structure.
Methods
Equals(DefaultableInt32)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(DefaultableInt32 other)
| Parameter | Type | Description |
|---|---|---|
| other | DefaultableInt32 | An object to compare with this object. |
Returns
- bool:
trueif the current object is equal to theotherparameter; otherwise,false.
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
| Parameter | Type | Description |
|---|---|---|
| obj | object | The object to compare with the current instance. |
Returns
- bool:
trueifobjand this instance are the same type and represent the same value; otherwise,false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int:
A 32-bit signed integer that is the hash code for this instance.
Operators
operator ==(DefaultableInt32, DefaultableInt32)
Compares two objects for equality.
public static bool operator ==(DefaultableInt32 left, DefaultableInt32 right)
| Parameter | Type | Description |
|---|---|---|
| left | DefaultableInt32 | A DefaultableInt32 to compare. |
| right | DefaultableInt32 | A DefaultableInt32 to compare. |
Returns
- bool:
trueif the values ofleftandrightare equal; otherwise,false.
explicit operator int(DefaultableInt32)
Explicitly converts a DefaultableInt32 to an int.
public static explicit operator int(DefaultableInt32 value)
| Parameter | Type | Description |
|---|---|---|
| value | DefaultableInt32 | The DefaultableInt32 to convert. |
Returns
implicit operator DefaultableInt32(int)
Implicitly converts an int to a DefaultableInt32.
public static implicit operator DefaultableInt32(int value)
| Parameter | Type | Description |
|---|---|---|
| value | int | The int to convert. |
Returns
- DefaultableInt32:
The DefaultableInt32 that was created.
operator !=(DefaultableInt32, DefaultableInt32)
Compares two objects for inequality.
public static bool operator !=(DefaultableInt32 left, DefaultableInt32 right)
| Parameter | Type | Description |
|---|---|---|
| left | DefaultableInt32 | A DefaultableInt32 to compare. |
| right | DefaultableInt32 | A DefaultableInt32 to compare. |
Returns
- bool:
trueif the values ofleftandrightare unequal; otherwise,false.