Struct Variant
A strongly typed object that readily casts an intrinsic
object to the other intrinsic types when possible.
Implements
System.IConvertible
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
Assembly: FastReport.OpenSource.dll
Syntax
public struct Variant : IConvertible
Constructors
Variant(Object)
Creates a strongly typed object that readily casts a primitive
object to the other primitive types when possible.
Declaration
public Variant(object value)
Parameters
Type |
Name |
Description |
System.Object |
value |
|
Properties
ImplementsIConvertible
Returns true if the Value property implements System.IConvertible
Declaration
public bool ImplementsIConvertible { get; }
Property Value
Type |
Description |
System.Boolean |
|
IsDate
Returns true if the value is a date or can be parsed into a date.
Declaration
public bool IsDate { get; }
Property Value
Type |
Description |
System.Boolean |
|
IsNumberable
Returns true if the Value property
is a numeric intrinsic value or else can be parsed into
a numeric intrinsic value.
Declaration
public bool IsNumberable { get; }
Property Value
Type |
Description |
System.Boolean |
|
IsNumeric
Returns true if the Value property
is a numeric intrinsic value.
Declaration
public bool IsNumeric { get; }
Property Value
Type |
Description |
System.Boolean |
|
IsTimeSpan
Returns true if the value is a TimeSpan.
Declaration
public bool IsTimeSpan { get; }
Property Value
Type |
Description |
System.Boolean |
|
Type
The System.Type of the Value property.
Declaration
public Type Type { get; }
Property Value
Type |
Description |
System.Type |
|
Value
The actual value being stored in its original System.Type,
returned as an System.Object.
Declaration
public object Value { get; }
Property Value
Type |
Description |
System.Object |
|
Methods
CBln(Object)
Converts an object to a boolean.
For any type, if null, returns false.
For Boolean: true/false.
For String: "", "false", "0", etc. == false;
"1", "true", etc. == true, else true.
For numeric intrinsics: 0 == false, else true.
For any other non-null object, returns true.
Declaration
public static bool CBln(object bln)
Parameters
Type |
Name |
Description |
System.Object |
bln |
The string to be converted
|
Returns
Type |
Description |
System.Boolean |
The boolean value of this string.
|
Equals(Object)
See System.Object.Equals(System.Object).
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
System.ValueType.Equals(System.Object)
GetHashCode()
See System.Object.GetHashCode().
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
Overrides
System.ValueType.GetHashCode()
GetTypeCode()
Returns the System.TypeCode for this instance.
Declaration
public TypeCode GetTypeCode()
Returns
Type |
Description |
System.TypeCode |
The enumerated constant that is the System.TypeCode
of the class or value type that implements this interface.
|
ToBoolean()
If Value is a System.Boolean, returns
as-is. Otherwise, attempts to convert the value of this instance to
an equivalent System.Boolean value.
Declaration
Returns
Type |
Description |
System.Boolean |
|
If Value is a System.Boolean, returns
as-is. Otherwise, attempts to convert the value of this instance to
an equivalent System.Boolean value using the specified culture-specific
formatting information.
Declaration
public bool ToBoolean(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.Boolean |
|
ToByte()
If Value is a System.Byte, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 8-bit unsigned integer.
Declaration
Returns
Type |
Description |
System.Byte |
|
If Value is a System.Byte, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 8-bit unsigned integer using the specified
culture-specific formatting information.
Declaration
public byte ToByte(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.Byte |
|
ToChar()
If Value is a System.Char, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent Unicode character.
Declaration
Returns
Type |
Description |
System.Char |
|
If Value is a System.Char, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent Unicode character using the specified
culture-specific formatting information.
Declaration
public char ToChar(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.Char |
|
ToDateTime()
If Value is a System.DateTime, returns
as-is. Otherwise, attempts to convert the value of this instance to
an equivalent DateTime.
Declaration
public DateTime ToDateTime()
Returns
Type |
Description |
System.DateTime |
|
If Value is a System.DateTime, returns
as-is. Otherwise, attempts to convert the value of this instance to
an equivalent DateTime using the specified culture-specific
formatting information.
Declaration
public DateTime ToDateTime(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.DateTime |
|
ToDateTimeOffset()
If Value is a System.DateTimeOffset, returns
as-is. Otherwise, attempts to convert the value of this instance to
an equivalent DateTimeOffset.
Declaration
public DateTimeOffset ToDateTimeOffset()
Returns
Type |
Description |
System.DateTimeOffset |
|
If Value is a System.DateTimeOffset, returns
as-is. Otherwise, attempts to convert the value of this instance to
an equivalent DateTimeOffset using the specified culture-specific
formatting information.
Declaration
public DateTimeOffset ToDateTimeOffset(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.DateTimeOffset |
|
ToDecimal()
If Value is a System.Decimal, returns
as-is. Otherwise, attempts to convert the value of this instance to
an equivalent Decimal number.
Declaration
public decimal ToDecimal()
Returns
Type |
Description |
System.Decimal |
|
If Value is a System.Decimal, returns
as-is. Otherwise, attempts to convert the value of this instance to
an equivalent Decimal number using the specified culture-specific
formatting information.
Declaration
public decimal ToDecimal(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.Decimal |
|
ToDouble()
If Value is a System.Double, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent double-precision floating-point number.
Declaration
Returns
Type |
Description |
System.Double |
|
If Value is a System.Double, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent double-precision floating-point number using the
specified culture-specific formatting information.
Declaration
public double ToDouble(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.Double |
|
ToInt16()
If Value is a System.Int16, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 16-bit signed integer.
Declaration
Returns
Type |
Description |
System.Int16 |
|
If Value is a System.Boolean, returns
as-is. Otherwise, attempts to convert the value of this instance to
an equivalent 16-bit signed integer using the specified
culture-specific formatting information.
Declaration
public short ToInt16(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.Int16 |
|
ToInt32()
If Value is a System.Int32, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 32-bit signed integer.
Declaration
Returns
Type |
Description |
System.Int32 |
|
If Value is a System.Int32, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 32-bit signed integer using the specified
culture-specific formatting information.
Declaration
public int ToInt32(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.Int32 |
|
ToInt64()
If Value is a System.Int64, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 64-bit signed integer.
Declaration
Returns
Type |
Description |
System.Int64 |
|
If Value is a System.Int64, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 64-bit signed integer using the specified
culture-specific formatting information.
Declaration
public long ToInt64(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.Int64 |
|
ToSByte()
If Value is a System.SByte, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 8-bit signed integer.
Declaration
[CLSCompliant(false)]
public sbyte ToSByte()
Returns
Type |
Description |
System.SByte |
|
If Value is a System.SByte, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 8-bit signed integer using the specified
culture-specific formatting information.
Declaration
[CLSCompliant(false)]
public sbyte ToSByte(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.SByte |
|
ToSingle()
If Value is a System.Single, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent single-precision floating-point number.
Declaration
Returns
Type |
Description |
System.Single |
|
If Value is a System.Single, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent single-precision floating-point number using the
specified culture-specific formatting information.
Declaration
public float ToSingle(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.Single |
|
ToString()
Returns FastReport.Variant.String property unless the value on the right
is null. If the value on the right is null, returns "".
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.ValueType.ToString()
Converts the value of this instance to an equivalent FastReport.Variant.String
using the specified culture-specific formatting information.
Declaration
public string ToString(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
|
Returns
Type |
Description |
System.String |
|
ToTimeSpan()
If Value is a System.TimeSpan, returns
as-is. Otherwise, attempts to convert the value of this instance to
an equivalent TimeSpan.
Declaration
public TimeSpan ToTimeSpan()
Returns
Type |
Description |
System.TimeSpan |
|
If Value is a System.TimeSpan, returns
as-is. Otherwise, attempts to convert the value of this instance to
an equivalent TimeSpan using the specified culture-specific
formatting information.
Declaration
public TimeSpan ToTimeSpan(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.TimeSpan |
|
ToType(Type)
Attempts to convert or typecast to the specified type.
Declaration
public object ToType(Type type)
Parameters
Type |
Name |
Description |
System.Type |
type |
The type to convert or cast to.
|
Returns
Type |
Description |
System.Object |
The object after typecasting.
|
Attempts to convert or typecast to the specified type.
Declaration
public object ToType(Type type, IFormatProvider provider)
Parameters
Type |
Name |
Description |
System.Type |
type |
The type to convert or cast to.
|
System.IFormatProvider |
provider |
An System.IFormatProvider
interface implementation that supplies culture-specific formatting information.
|
Returns
Type |
Description |
System.Object |
The object after typecasting.
|
ToUInt16()
If Value is a System.UInt16, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 16-bit unsigned integer.
Declaration
[CLSCompliant(false)]
public ushort ToUInt16()
Returns
Type |
Description |
System.UInt16 |
|
If Value is a System.UInt16, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 16-bit unsigned integer using the specified
culture-specific formatting information.
Declaration
[CLSCompliant(false)]
public ushort ToUInt16(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.UInt16 |
|
ToUInt32()
If Value is a System.UInt32, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 32-bit unsigned integer.
Declaration
[CLSCompliant(false)]
public uint ToUInt32()
Returns
Type |
Description |
System.UInt32 |
|
If Value is a System.UInt32, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 32-bit unsigned integer using the specified
culture-specific formatting information.
Declaration
[CLSCompliant(false)]
public uint ToUInt32(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.UInt32 |
|
ToUInt64()
If Value is a System.UInt64, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 64-bit unsigned integer.
Declaration
[CLSCompliant(false)]
public ulong ToUInt64()
Returns
Type |
Description |
System.UInt64 |
|
If Value is a System.UInt64, returns
as-is. Otherwise, attempts to convert the value of this instance
to an equivalent 64-bit unsigned integer using the specified
culture-specific formatting information.
Declaration
[CLSCompliant(false)]
public ulong ToUInt64(IFormatProvider formatProvider)
Parameters
Type |
Name |
Description |
System.IFormatProvider |
formatProvider |
The culture-specific formatting information.
|
Returns
Type |
Description |
System.UInt64 |
|
Operators
Addition(Variant, Object)
Declaration
public static Variant operator +(Variant subjectVariant, object value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.Object |
value |
|
Returns
Type |
Description |
Variant |
A new Variant containing the resulting value.
|
BitwiseAnd(Variant, Object)
Declaration
public static Variant operator &(Variant subjectVariant, object value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.Object |
value |
|
Returns
Type |
Description |
Variant |
A new Variant containing the resulting value.
|
Remarks
BitwiseOr(Variant, Object)
Declaration
public static Variant operator |(Variant subjectVariant, object value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.Object |
value |
|
Returns
Type |
Description |
Variant |
A new Variant containing the resulting value.
|
Division(Variant, Object)
Declaration
public static Variant operator /(Variant subjectVariant, object value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.Object |
value |
|
Returns
Type |
Description |
Variant |
A new Variant containing the resulting value.
|
Equality(Variant, Object)
Equality operator.
First attempts to compare the left value after
temporarily converting it to the type of the right value.
If the conversion cannot occur, such as if the value is not an
intrinsic value type, the comparison occurs at the System.Object
level using Object.Equals.
Declaration
public static bool operator ==(Variant subjectVariant, object value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.Object |
value |
|
Returns
Type |
Description |
System.Boolean |
|
Equality(Variant, String)
Declaration
public static bool operator ==(Variant subjectVariant, string value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.String |
value |
|
Returns
Type |
Description |
System.Boolean |
|
GreaterThan(Variant, Object)
Declaration
public static bool operator>(Variant subjectVariant, object value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.Object |
value |
|
Returns
Type |
Description |
System.Boolean |
|
GreaterThanOrEqual(Variant, Object)
Greater than or equal operator.
Declaration
public static bool operator >=(Variant subjectVariant, object value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.Object |
value |
|
Returns
Type |
Description |
System.Boolean |
|
Implicit(Variant to Boolean)
Declaration
public static implicit operator bool (Variant v)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Implicit(Variant to Byte)
Declaration
public static implicit operator byte (Variant v)
Parameters
Returns
Type |
Description |
System.Byte |
|
Implicit(Variant to Char)
Declaration
public static implicit operator char (Variant v)
Parameters
Returns
Type |
Description |
System.Char |
|
Implicit(Variant to DateTime)
Declaration
public static implicit operator DateTime(Variant v)
Parameters
Returns
Type |
Description |
System.DateTime |
|
Implicit(Variant to Decimal)
Declaration
public static implicit operator decimal (Variant v)
Parameters
Returns
Type |
Description |
System.Decimal |
|
Implicit(Variant to Double)
Declaration
public static implicit operator double (Variant v)
Parameters
Returns
Type |
Description |
System.Double |
|
Implicit(Variant to Int16)
Declaration
public static implicit operator short (Variant v)
Parameters
Returns
Type |
Description |
System.Int16 |
|
Implicit(Variant to Int32)
Declaration
public static implicit operator int (Variant v)
Parameters
Returns
Type |
Description |
System.Int32 |
|
Implicit(Variant to Int64)
Declaration
public static implicit operator long (Variant v)
Parameters
Returns
Type |
Description |
System.Int64 |
|
Implicit(Variant to SByte)
Declaration
[CLSCompliant(false)]
public static implicit operator sbyte (Variant v)
Parameters
Returns
Type |
Description |
System.SByte |
|
Implicit(Variant to Single)
Declaration
public static implicit operator float (Variant v)
Parameters
Returns
Type |
Description |
System.Single |
|
Implicit(Variant to String)
Declaration
public static implicit operator string (Variant v)
Parameters
Returns
Type |
Description |
System.String |
|
Implicit(Variant to TimeSpan)
Declaration
public static implicit operator TimeSpan(Variant v)
Parameters
Returns
Type |
Description |
System.TimeSpan |
|
Implicit(Variant to UInt16)
Declaration
[CLSCompliant(false)]
public static implicit operator ushort (Variant v)
Parameters
Returns
Type |
Description |
System.UInt16 |
|
Implicit(Variant to UInt32)
Declaration
[CLSCompliant(false)]
public static implicit operator uint (Variant v)
Parameters
Returns
Type |
Description |
System.UInt32 |
|
Implicit(Variant to UInt64)
Declaration
[CLSCompliant(false)]
public static implicit operator ulong (Variant v)
Parameters
Returns
Type |
Description |
System.UInt64 |
|
Implicit(Boolean to Variant)
Declaration
public static implicit operator Variant(bool v)
Parameters
Type |
Name |
Description |
System.Boolean |
v |
|
Returns
Implicit(Byte to Variant)
Declaration
public static implicit operator Variant(byte v)
Parameters
Type |
Name |
Description |
System.Byte |
v |
|
Returns
Implicit(Char to Variant)
Declaration
public static implicit operator Variant(char v)
Parameters
Type |
Name |
Description |
System.Char |
v |
|
Returns
Implicit(DateTime to Variant)
Declaration
public static implicit operator Variant(DateTime v)
Parameters
Type |
Name |
Description |
System.DateTime |
v |
|
Returns
Implicit(Decimal to Variant)
Declaration
public static implicit operator Variant(decimal v)
Parameters
Type |
Name |
Description |
System.Decimal |
v |
|
Returns
Implicit(Double to Variant)
Declaration
public static implicit operator Variant(double v)
Parameters
Type |
Name |
Description |
System.Double |
v |
|
Returns
Implicit(Int16 to Variant)
Declaration
public static implicit operator Variant(short v)
Parameters
Type |
Name |
Description |
System.Int16 |
v |
|
Returns
Implicit(Int32 to Variant)
Declaration
public static implicit operator Variant(int v)
Parameters
Type |
Name |
Description |
System.Int32 |
v |
|
Returns
Implicit(Int64 to Variant)
Declaration
public static implicit operator Variant(long v)
Parameters
Type |
Name |
Description |
System.Int64 |
v |
|
Returns
Implicit(SByte to Variant)
Declaration
[CLSCompliant(false)]
public static implicit operator Variant(sbyte v)
Parameters
Type |
Name |
Description |
System.SByte |
v |
|
Returns
Implicit(Single to Variant)
Declaration
public static implicit operator Variant(float v)
Parameters
Type |
Name |
Description |
System.Single |
v |
|
Returns
Implicit(String to Variant)
Declaration
public static implicit operator Variant(string v)
Parameters
Type |
Name |
Description |
System.String |
v |
|
Returns
Implicit(TimeSpan to Variant)
Declaration
public static implicit operator Variant(TimeSpan v)
Parameters
Type |
Name |
Description |
System.TimeSpan |
v |
|
Returns
Implicit(UInt16 to Variant)
Declaration
[CLSCompliant(false)]
public static implicit operator Variant(ushort v)
Parameters
Type |
Name |
Description |
System.UInt16 |
v |
|
Returns
Implicit(UInt32 to Variant)
Declaration
[CLSCompliant(false)]
public static implicit operator Variant(uint v)
Parameters
Type |
Name |
Description |
System.UInt32 |
v |
|
Returns
Implicit(UInt64 to Variant)
Declaration
[CLSCompliant(false)]
public static implicit operator Variant(ulong v)
Parameters
Type |
Name |
Description |
System.UInt64 |
v |
|
Returns
Inequality(Variant, Object)
Declaration
public static bool operator !=(Variant subjectVariant, object value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.Object |
value |
|
Returns
Type |
Description |
System.Boolean |
The opposite of ==
|
Inequality(Variant, String)
Declaration
public static bool operator !=(Variant subjectVariant, string value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.String |
value |
|
Returns
Type |
Description |
System.Boolean |
|
LessThan(Variant, Object)
Declaration
public static bool operator <(Variant subjectVariant, object value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.Object |
value |
|
Returns
Type |
Description |
System.Boolean |
|
LessThanOrEqual(Variant, Object)
Less than or equal operator.
Declaration
public static bool operator <=(Variant subjectVariant, object value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.Object |
value |
|
Returns
Type |
Description |
System.Boolean |
|
Modulus(Variant, Object)
Declaration
public static Variant operator %(Variant subjectVariant, object value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.Object |
value |
|
Returns
Type |
Description |
Variant |
A new Variant containing the resulting value.
|
Multiply(Variant, Object)
Declaration
public static Variant operator *(Variant subjectVariant, object value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.Object |
value |
|
Returns
Type |
Description |
Variant |
A new Variant containing the resulting value.
|
Subtraction(Variant, Object)
Declaration
public static Variant operator -(Variant subjectVariant, object value)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
System.Object |
value |
|
Returns
Type |
Description |
Variant |
A new Variant containing the resulting value.
|
UnaryNegation(Variant)
Declaration
public static Variant operator -(Variant subjectVariant)
Parameters
Type |
Name |
Description |
Variant |
subjectVariant |
|
Returns
Implements
System.IConvertible