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
Hitesh Chaudhari 10Hitesh Chaudhari 10 

How to type cast set to list

I am having one Set having data type as String and One List of type 'GroupMember'.

I want to type cast it . Tell me way to type cast it .

Set<String> mergelist=new Set<String>();

List<GroupMember>  newGroupMember = new List<GroupMember>(); 

I want to insert mergelist data into newGroupMember list.
Best Answer chosen by Hitesh Chaudhari 10
NagendraNagendra (Salesforce Developers) 
Hi Hitesh,


You can use addAll() method of List collection to create a list from a set.
Example:

Set<String> setcollection =new Set<String>();
setcollection.add('xxx');
setcollection.add('yyy');

List<String> listcollection=new List<String>();
listcollection.addAll(s);
Similarly, you can tweak the above code as per your requirement which might help you overcome with the above challenge.

Please let us know if this helps.

Kindly mark this as solved if the information was helpful.

Thanks,
Nagendra