Click or drag to resize

EnumExtensionsToIntDefaultNullTEnum Method

[This is preliminary documentation and is subject to change.]

Converts an enum value to an integer. If value is NULL, then we stick with NULL. If value is equal to defaultValue, then we return NULL too.

Namespace:  CSInfrastructure.Extensions
Assembly:  CSInfrastructure (in CSInfrastructure.dll) Version: 1.13.0+Branch.master.Sha.d583fc64569355d188a9c0818d257b6d0d3e1339
Syntax
C#
public static int? ToIntDefaultNull<TEnum>(
	this TEnum? value,
	TEnum defaultValue
)
where TEnum : struct, new()

Parameters

value
Type: SystemNullableTEnum
The enum value to convert
defaultValue
Type: TEnum
The enum value to check against to determine if we should return NULL or not

Type Parameters

TEnum
The type of enum

Return Value

Type: NullableInt32
An integer value or NULL

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type NullableTEnum. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also