C# How to add placement variable into a resource string

c#, resources

Solution

As Jeff Johnson mentioned in his answer, it basically the exact same thing as the original Console.WriteLine(). The resource string is just a string. So you reference the resource file and do the format.

If you need it for something other than the Console you can use the String.Format():

  var newString = String.Format(resources.jimstring, xmlscript);

Problem

This should be easy, but can't find anything to explain it. Say I am writing something out on console.writeln like: `console.writeln("Jim is a {0} ", xmlscript);` Say I wanted to convert string `"Jim is.." to a resource string in a global resource.resx. It would be: `jimstring jim is a {0}` and I would refer to it in code as `console.writeln(Resources.jimstring)` How to I put the placement variable (`xmlscript`) (is this what they are called?) into the resource string in console.writeln? Thanks, Bob

Original source