Find your content:

Search form

You are here

Compile Error: Illegal assignment from Decimal to Integer

itemlst.Quantity = templook[i].Quantity__c;

Here Quantity is of integer type and Quantity_c is of decimal type.How can I convert Quantity_c into Integer

Attribution to: Eagerin Sf

Possible Suggestion/Solution #1

itemlst.Quantity = integer.valueOf(templook[i].Quantity__c);

Integer.valueOf will work.


 Decimal myDecimal = 4.12;
 Integer a=myDecimal.intValue();

I used Decimal.intValue() and it works as shown.

Attribution to: Mohith Shrivastava
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content