Convert List to Set in Salesforce

The simplest way to convert List to Set in Salesforce is given below:    

        List<String> tempList = new List<String>();
        Set<String> tempSet = new Set<String>();
        
        tempList.add('One');
        tempList.add('Two');
        tempList.add('Three');  
        
        tempSet.addAll(tempList); 

tempList is List datatype and tempSet is Set datatype.
Add some values to List datatype and use addAll() to add it to Set datatype.


Cheers!!!