Pip-Services-Commons-Dotnet
Static Public Member Functions | List of all members
PipServices3.Commons.Convert.IntegerConverter Class Reference

Converts arbitrary values into integer using extended conversion rules: More...

Static Public Member Functions

static int ToNullableInteger (object value)
 Converts value into integer or returns null when conversion is not possible. More...
 
static int ToInteger (object value)
 Converts value into integer or returns 0 when conversion is not possible. More...
 
static int ToIntegerWithDefault (object value, int defaultValue)
 Converts value into integer or returns default when conversion is not possible. More...
 

Detailed Description

Converts arbitrary values into integer using extended conversion rules:

var value1 = IntegerConverter.ToNullableInteger("ABC"); // Result: null
var value2 = IntegerConverter.ToNullableInteger("123.456"); // Result: 123.456
var value3 = IntegerConverter.ToNullableInteger(true); // Result: 1
var value4 = IntegerConverter.ToNullableInteger(new Date()); // Result: current milliseconds

Member Function Documentation

◆ ToInteger()

static int PipServices3.Commons.Convert.IntegerConverter.ToInteger ( object  value)
static

Converts value into integer or returns 0 when conversion is not possible.

Parameters
valuethe value to convert
Returns
integer value or 0 when conversion is not supported.

◆ ToIntegerWithDefault()

static int PipServices3.Commons.Convert.IntegerConverter.ToIntegerWithDefault ( object  value,
int  defaultValue 
)
static

Converts value into integer or returns default when conversion is not possible.

Parameters
valuethe value to convert
defaultValuethe default value
Returns
integer value or default when conversion is not supported.

◆ ToNullableInteger()

static int PipServices3.Commons.Convert.IntegerConverter.ToNullableInteger ( object  value)
static

Converts value into integer or returns null when conversion is not possible.

Parameters
valuethe value to convert
Returns
integer value or null when conversion is not supported.

The documentation for this class was generated from the following file: