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
MrithulaMrithula 

comma separated values to list values...

hi,

 

i have a list that contains comma separated values (for eg, answerlist ) .

 

now i want to remove the commas and to store the values un a list..which i want to add to the wrapper...

 

 

 anyone help me to do this...

Best Answer chosen by Admin (Salesforce Developers) 
Bhawani SharmaBhawani Sharma
for(String key : answerlist.Evaluation__c.split(','))
{
wrapperList.add(new Wrapper(key));
}

All Answers

nickwick76nickwick76

Hi,

Can you give an example?

What does the first list looks like? Or is it a string?

 

// Niklas

s_k_as_k_a

 

 

Here is the example

 

String  valstring = 'a,b,c,d';

String[]  strs =  valstring.spilt(',');

 

Bhawani SharmaBhawani Sharma
String str` = 'a,b,c,d';
for(String key : str.split(','))
{
wrapperList.add(new Wrapper(key));
}
MrithulaMrithula

my values are present in the list , not in the string variable.

 

for eg:

 

answerlist=[select Evaluation__c from Result__c where id=:resultdetail.Id] ;

 

here Evaluation__c contains the values like ( True, image, 2,"text/logo")

 

 

so how can i get comma separated values from answerlist

Bhawani SharmaBhawani Sharma
for(String key : answerlist.Evaluation__c.split(','))
{
wrapperList.add(new Wrapper(key));
}
This was selected as the best answer