using System;
namespace System
{
/// Represents an object whose underlying type is a value type that can also be assigned null like a reference type.
/// The underlying value type of the generic type.
/// 1
// Token: 0x02000060 RID: 96
[Serializable]
public struct Nullable where T : struct
{
/// Initializes a new instance of the structure to the specified value.
/// A value type.
// Token: 0x060006B3 RID: 1715 RVA: 0x000150F4 File Offset: 0x000132F4
public Nullable(T value)
{
this.has_value = true;
this.value = value;
}
/// Gets a value indicating whether the current object has a value.
/// true if the current object has a value; false if the current object has no value.
// Token: 0x170000C9 RID: 201
// (get) Token: 0x060006B4 RID: 1716 RVA: 0x00015104 File Offset: 0x00013304
public bool HasValue
{
get
{
return this.has_value;
}
}
/// Gets the value of the current value.
/// The value of the current object if the property is true. An exception is thrown if the property is false.
/// The property is false.
// Token: 0x170000CA RID: 202
// (get) Token: 0x060006B5 RID: 1717 RVA: 0x0001510C File Offset: 0x0001330C
public T Value
{
get
{
if (!this.has_value)
{
throw new InvalidOperationException("Nullable object must have a value.");
}
return this.value;
}
}
/// Indicates whether the current object is equal to a specified object.
/// true if the parameter is equal to the current object; otherwise, false. This table describes how equality is defined for the compared values: Return ValueDescriptiontrueThe property is false, and the parameter is null. That is, two null values are equal by definition.-or-The property is true, and the value returned by the property is equal to the parameter.falseThe property for the current structure is true, and the parameter is null.-or-The property for the current structure is false, and the parameter is not null.-or-The property for the current structure is true, and the value returned by the property is not equal to the parameter.
/// An object.
/// 1
// Token: 0x060006B6 RID: 1718 RVA: 0x0001512C File Offset: 0x0001332C
public override bool Equals(object other)
{
if (other == null)
{
return !this.has_value;
}
return other is T? && this.Equals((T?)other);
}
// Token: 0x060006B7 RID: 1719 RVA: 0x00015158 File Offset: 0x00013358
private bool Equals(T? other)
{
return other.has_value == this.has_value && (!this.has_value || other.value.Equals(this.value));
}
/// Retrieves the hash code of the object returned by the property.
/// The hash code of the object returned by the property if the property is true, or zero if the property is false.
/// 1
// Token: 0x060006B8 RID: 1720 RVA: 0x000151A4 File Offset: 0x000133A4
public override int GetHashCode()
{
if (!this.has_value)
{
return 0;
}
return this.value.GetHashCode();
}
/// Retrieves the value of the current object, or the object's default value.
/// The value of the property if the property is true; otherwise, the default value of the current object. The type of the default value is the type argument of the current object, and the value of the default value consists solely of binary zeroes.
// Token: 0x060006B9 RID: 1721 RVA: 0x000151C4 File Offset: 0x000133C4
public T GetValueOrDefault()
{
return (!this.has_value) ? default(T) : this.value;
}
/// Retrieves the value of the current object, or the specified default value.
/// The value of the property if the property is true; otherwise, the parameter.
/// A value to return if the property is false.
// Token: 0x060006BA RID: 1722 RVA: 0x000151F0 File Offset: 0x000133F0
public T GetValueOrDefault(T defaultValue)
{
return (!this.has_value) ? defaultValue : this.value;
}
/// Returns the text representation of the value of the current object.
/// The text representation of the value of the current object if the property is true, or an empty string ("") if the property is false.
/// 1
// Token: 0x060006BB RID: 1723 RVA: 0x0001520C File Offset: 0x0001340C
public override string ToString()
{
if (this.has_value)
{
return this.value.ToString();
}
return string.Empty;
}
// Token: 0x060006BC RID: 1724 RVA: 0x0001523C File Offset: 0x0001343C
private static object Box(T? o)
{
if (!o.has_value)
{
return null;
}
return o.value;
}
// Token: 0x060006BD RID: 1725 RVA: 0x00015258 File Offset: 0x00013458
private static T? Unbox(object o)
{
if (o == null)
{
return null;
}
return new T?((T)((object)o));
}
/// Creates a new object initialized to a specified value.
/// A object whose property is initialized with the parameter.
/// A value type.
// Token: 0x060006BE RID: 1726 RVA: 0x00015280 File Offset: 0x00013480
public static implicit operator T?(T value)
{
return new T?(value);
}
/// Returns the value of a specified value.
/// The value of the property for the parameter.
/// A value.
// Token: 0x060006BF RID: 1727 RVA: 0x00015288 File Offset: 0x00013488
public static explicit operator T(T? value)
{
return value.Value;
}
// Token: 0x040000BC RID: 188
internal T value;
// Token: 0x040000BD RID: 189
internal bool has_value;
}
}