[SalesForce] Custom Label: Passing Parameter

I have looked at this question but this is not working and I have the exact same requirement where I will have to pass the parameter to a custom label

string parameter = 'this is a test';
string label =  System.Label.test;
String value = String.format(label, parameter); 
System.debug('//' + value);

Here is the error:

Variable does not exist: String

Best Answer

You need a List to send 'parameter'

String value = String.format(label, new List<String>{ parameter });