.net - c# $ string in resource -
i need add $"test message {variable1} , {variable2}" kind of string resource file.
earlier can done using string builder format below
test message {0} , {1} let me know there alternative doing $ string format
$"test message {variable1} , {variable2}" syntactic sugar string.format("test message {0} , {1}", variable1, variable2).
you can put static values in resources. can't put dynamic values formatted string dynamic values.
if want use string interpolation this, need key resources formats , this:
string r(formattablestring fs) { return string.format(resources.getstring(fs.format), fs.getarguments()); } // uses "test message {0} , {1}" resource key r($"test message {variable1} , {variable2}");
Comments
Post a Comment