-
Notifications
You must be signed in to change notification settings - Fork 12
Features: Named parameters for String Formatting
Rudy Huyn edited this page Aug 1, 2019
·
1 revision
By default, ReswPlus will generate random names for the parameters used for string formatting. In addition to their types, you can specify the name you want ReswPlus to use.
Example:
The resource:
Key | Value | Comment |
---|---|---|
ForecastAnnouncement | The temperature in {2} is {0}°F ({1}°C) | #Format[Int32 fahrenheit, Int32 celsius, String city] |
will generate the following code, with strong type and named parameters based on the hashtag in the comment section):
#region ForecastAnnouncement
/// <summary>
/// Format the string similar to: The current temperature in {2} is {0}°F ({1}°C)
/// </summary>
public static string ForecastAnnouncement(int tempFahrenheit, int tempCelsius, string city)
{
return string.Format(_resourceLoader.GetString("ForecastAnnouncement"), tempFahrenheit, tempCelsius, city);
}
#endregion