| TypeCode | |
Crutches needed all around... TypeCode.Empty is described as the type code
for "a null reference". Unfortunately the only way to retrieve a TypeCode
is from a Type object, which can't represent the type of a null reference
(well... actually one can't really talk about a _type_ of a _null_ reference
in C# at all as far as I understand).
Well anyway, wrapping up the rant, this function fills in the spot of a
function that's clearly missing: Type.GetTypeCode(object), which returns
TypeCode.Empty if asked to get the type of a null object.
Something at the back of my mind tells me that there's one way of looking at
this where the behaviour of the existing API would make sense... but really,
I think this is how it really should have been since it is a lot more useful.
|
| bool | |
Returns true if the specified type is integer-compatible (in other words, a string of digits can be
converted to it using ExactConvert). This includes all types that are ExactConvert.IsTrueIntegerType(Type)
as well as DateTime, Char and Boolean.
|
| bool | |
| bool | |
Returns true if the specified type is a supported type for converting to other
types supported by ExactConvert.
|
| bool | |
Returns true if the specified type code is that of a supported type for converting to
other types supported by ExactConvert.
|
| bool | |
Returns true if the specified type is a nullable form of one of the 8 built-in "true" integer types:
the signed and unsigned 8, 16, 32 and 64-bit types.
|
| bool | |
Returns true if the specified type is one of the 8 built-in "true" integer types:
the signed and unsigned 8, 16, 32 and 64-bit types.
|
| bool | |
| void | To(object value, out bool result) |
Converts the specified object to a bool.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| void | To(object value, out byte result) |
Converts the specified object to a byte.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| void | To(object value, out sbyte result) |
Converts the specified object to an sbyte.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| void | To(object value, out short result) |
Converts the specified object to a short.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| void | To(object value, out ushort result) |
Converts the specified object to a ushort.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| void | To(object value, out int result) |
Converts the specified object to an int.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| void | To(object value, out uint result) |
Converts the specified object to a uint.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| void | To(object value, out long result) |
Converts the specified object to a long.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| void | To(object value, out ulong result) |
Converts the specified object to a ulong.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| void | To(object value, out float result) |
Converts the specified object to a float.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| void | To(object value, out double result) |
Converts the specified object to a double.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| void | To(object value, out decimal result) |
Converts the specified object to a decimal.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| void | To(object value, out DateTime result) |
Converts the specified object to a DateTime.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| void | To(object value, out char result) |
Converts the specified object to a char.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| void | To(object value, out string result) |
Converts the specified object to a string.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| object | To(Type toType, object value) |
Converts the value to type toType. Throws an
ExactConvertException if the object cannot be converted exactly.
|
| T | |
Converts the value to type T. Throws an
ExactConvertException if the object cannot be converted exactly.
|
| bool | |
Converts the specified object to a bool.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| byte | |
Converts the specified object to a byte.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| char | |
Converts the specified object to a char.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| DateTime | |
Converts the specified object to a DateTime.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| decimal | |
Converts the specified object to a decimal.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| double | |
Converts the specified object to a double.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| float | |
Converts the specified object to a float.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| int | |
Converts the specified object to an int.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| long | |
Converts the specified object to a long.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| sbyte | |
Converts the specified object to an sbyte.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| short | |
Converts the specified object to a short.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| string | |
Converts the specified object to a string.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| uint | |
Converts the specified object to a uint.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| ulong | |
Converts the specified object to a ulong.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| ushort | |
Converts the specified object to a ushort.
Throws an ExactConvertException if the object cannot be converted exactly.
|
| bool | Try(object value, out byte result) |
Converts the specified object to a byte.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value if the conversion is unsuccessful.
|
| bool | Try(object value, out ushort result) |
Converts the specified object to a ushort.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value
if the conversion is unsuccessful.
|
| bool | Try(object value, out uint result) |
Converts the specified object to a uint.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value
if the conversion is unsuccessful.
|
| bool | Try(object value, out ulong result) |
Converts the specified object to a ulong.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value
if the conversion is unsuccessful.
|
| bool | Try(object value, out sbyte result) |
Converts the specified object to an sbyte.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value
if the conversion is unsuccessful.
|
| bool | Try(object value, out short result) |
Converts the specified object to a short.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value
if the conversion is unsuccessful.
|
| bool | Try(object value, out int result) |
Converts the specified object to an int.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value
if the conversion is unsuccessful.
|
| bool | Try(object value, out long result) |
Converts the specified object to a long.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value
if the conversion is unsuccessful.
|
| bool | Try(object value, out bool result) |
Converts the specified object to a bool.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value
if the conversion is unsuccessful.
If the value is one of the integer types, the exact conversion only succeeds
if the value is in range, i.e. 0 or 1. If converting from a string, the string
must be exactly (case-insensitive) equal to "True" or "False", or the conversion
will fail.
|
| bool | Try(object value, out char result) |
Converts the specified object to a char.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value
if the conversion is unsuccessful.
|
| bool | Try(object value, out DateTime result) |
Converts the specified object to a DateTime.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value
if the conversion is unsuccessful.
When converting from string, supports a subset of the ISO 8601 formats - for
more details see DateTimeExtensions.TryParseIso(string, out DateTime).
|
| bool | Try(object value, out float result) |
Converts the specified object to a float.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value
if the conversion is unsuccessful.
|
| bool | Try(object value, out double result) |
Converts the specified object to a double.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value
if the conversion is unsuccessful.
|
| bool | Try(object value, out decimal result) |
Converts the specified object to a decimal.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value
if the conversion is unsuccessful.
|
| bool | Try(object value, out string result) |
Converts the specified object to a string.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to the type's default value
if the conversion is unsuccessful, which in this case means null (!!!).
Note that the result will only ever be false if the value is one of the
unsupported types - all supported types can be converted to a string.
(So can the unsupported ones but it's a different matter. Unsupported types
are not supported by this method for consistency with the other overloads.)
|
| bool | Try(Type toType, object value, out object result) |
Converts the specified object to the type toType.
Returns true if successful, or false if the object cannot be converted exactly.
result is set to null
if the conversion is unsuccessful.
|
| long | |
C# does not allow a boxed integer type to be unboxed as anything other
than the true type of the boxed integer. This utility function unboxes the
integer as the correct type and then casts it to a long, returning the result.
Throws an exception if the object is null or not one of the built-in integer
types.
Does not support unboxing of a ulong because the cast to long would be lossy
and misleading. Will throw an exception when given a boxed ulong.
|
| long | |
A faster version of UnboxIntegerToLong(object) if the TypeCode is
already provided. Behaviour is undefined if typeCode does not match
the type of the object passed in.
|