Find your content:

Search form

You are here

Compile Error: Illegal assignment from Decimal to Integer

 
Share
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

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_integer.htm

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

Integer.valueOf will work.

Edit:

 Decimal myDecimal = 4.12;
 Integer a=myDecimal.intValue();
  System.debug('*****'+a);

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


Attribution to: Mohith Shrivastava
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4628

My Block Status

My Block Content