Class GorgonNullExtensions
Extension methods for null checking on reference types and nullable types.
Inherited Members
Namespace: Gorgon.Core
Assembly: Gorgon.Core.dll
Syntax
public static class GorgonNullExtensions
Methods
| Edit this page View SourceAsNullable<T>(object)
Function to return the value as a nullable type.
Declaration
public static T? AsNullable<T>(this object value) where T : struct
Parameters
Type | Name | Description |
---|---|---|
object | value | The value to convert. |
Returns
Type | Description |
---|---|
T? | The value as a nullable value type. |
Type Parameters
Name | Description |
---|---|
T | The type of value to convert to, must be a value type. |
IfNull<T>(object, T)
Function to check an object for null or DBNull and return a substitute value.
Declaration
public static T IfNull<T>(this object value, T substitutionValue)
Parameters
Type | Name | Description |
---|---|---|
object | value | The value to check. |
T | substitutionValue | The value used to replace the return value if the original value is null or DBNull. |
Returns
Type | Description |
---|---|
T | The original |
Type Parameters
Name | Description |
---|---|
T | The type of value. |
IsNull(object)
Determines whether the specified value is null.
Declaration
public static bool IsNull(this object value)
Parameters
Type | Name | Description |
---|---|---|
object | value | The value to check. |
Returns
Type | Description |
---|---|
bool |
|
Remarks
This will check an object for null and DBNull.