0

How to assign a set to List... I am getting the following error ..

Incompatible element type Set for collection of System.SelectOption

public List<SelectOption> cpOptions {
        get {
            if (cpOptions== null) {
                cpOptions = new List<SelectOption>();
            }
            return cpOptions ;
        }
        set;
        }

    public Set<String> cpOptions1{
        get {
            if (cpOptions1== null) {
                cpOptions1= new Set<String>();
            }
            return cpOptions1;
        }
        set;
        }

             cpOptions.add(cpOptions1);
             cpOptions1.add(cp1.Emp__c);
0

Take a look at the addAll method in the List Class: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_list.htm.

You are going to have another problem though because your Set and List are not of the same data type. You probably want to be converting your Set<String> to a List<String> after it has been constructed and loop over it to add new SelectOption instances to your List<SelectOption>.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.