问题
My question is about resource files (.resx) in c#.(the "strings" part) I'm using it to store my messages,and I want to know how can we use the "value" of a resource entry with parameters ?!
example :
Name : ShowCellValue Value : value on cell : ? and row : ? is : ?
and I want to fill the "?" parameters with different values.
Thank you,
回答1:
You can use string.Format on strings stored in your resource files.
Store ShowCellValue as
string showCellValue = "value on cell {0} and row {1} is {2}";
Then when you want to use it, just use the ResourceManager:
ResourceManager rm = new ResourceManager("resource root name",
Assembly.GetExecutingAssembly());
MessageBox.Show(string.Format(rm.GetString("showCellValue"),
cellName, rowName, cellValue);
来源:https://stackoverflow.com/questions/3537159/using-resource-files-with-parameters