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

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

Static Public Member Functions

static long ToNullableLong (object value)
 Converts value into long or returns null when conversion is not possible. More...
 
static long ToLong (object value)
 Converts value into long or returns 0 when conversion is not possible. More...
 
static long ToLongWithDefault (object value, long defaultValue)
 Converts value into long or returns default when conversion is not possible. More...
 

Detailed Description

Converts arbitrary values into longs using extended conversion rules:

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

Member Function Documentation

◆ ToLong()

static long PipServices3.Commons.Convert.LongConverter.ToLong ( object  value)
static

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

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

◆ ToLongWithDefault()

static long PipServices3.Commons.Convert.LongConverter.ToLongWithDefault ( object  value,
long  defaultValue 
)
static

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

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

◆ ToNullableLong()

static long PipServices3.Commons.Convert.LongConverter.ToNullableLong ( object  value)
static

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

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

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