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

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

Static Public Member Functions

static float ToNullableFloat (object value)
 Converts value into float or returns null when conversion is not possible. More...
 
static float ToFloat (object value)
 Converts value into float or returns 0 when conversion is not possible. More...
 
static float ToFloatWithDefault (object value, float defaultValue)
 Converts value into float or returns default when conversion is not possible. More...
 

Detailed Description

Converts arbitrary values into float using extended conversion rules:

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

Member Function Documentation

◆ ToFloat()

static float PipServices3.Commons.Convert.FloatConverter.ToFloat ( object  value)
static

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

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

◆ ToFloatWithDefault()

static float PipServices3.Commons.Convert.FloatConverter.ToFloatWithDefault ( object  value,
float  defaultValue 
)
static

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

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

◆ ToNullableFloat()

static float PipServices3.Commons.Convert.FloatConverter.ToNullableFloat ( object  value)
static

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

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

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