function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sandeep3385sandeep3385 

conversion of list of type object to integer

How to convert a list of custom object type to integer data type? Is there any type casting in apex to do it? Anyone please suggest
werewolfwerewolf

You can't just convert a custom object to an integer.  A custom object is a collection of fields.  An integer is a number.

 

If your custom object has an number-typed field that you'd like to use in a list of integers, then you can just make a List<Integer>, iterate through your list of custom objects, and call add() on your List<Integer> for each value of that number-typed field in the custom object.

sandeep3385sandeep3385

I have taken all the integer values into a custom object type list variable and assigned each of it to an integer variable by using .column name format.

 

Example: Integer i = values[0].Base_Price__c

 

Its working...