Can't convert from 'double?' to "decimal"

I am reading an XML file and I am parsing information. I am trying to convert double to int as

var pruebaPago = Math.Ceiling(row[i].Pagado);

      

but when i run my code i get the following error:

cannot convert from 'double?' to 'decimal'

      

XML file has the following definition for Pagado

<s:element name="Pagado" type="s:double" nillable="true"/>

      

How can I hide the nillable value and round it to the nearest integer?

+3


source to share


1 answer


You want to use Nullable<double>.Value

. You will also want to check that the value first is null

:

if (row[i].Pagado.HasValue)
{
    var pruebaPago = Math.Ceiling(row[i].Pagado.Value);
}

      



The current congestion resolution detects decimal

overloading the best match for Math.Ceiling

when you are transmitting double?

instead double

.

+7


source







All Articles