I have a method that receives a message and Priority enumeration and returns a formatted string.
private string FormatMessage(string message, Priority priority) { return string.Format("*{0,-6}* - {1}", priority, message); }
Priority has three possible values: High , Medium and Low .
I use string.Format alignment parameter to make the result look good. I would like the result to look like this:
*Low* - First message *Medium* - Second message *Low* - Third message
However, I get the following:
*Low * - First message *Medium* - Second message *Low * - Third message
I understand why this is happening, but I would like to know if there is a simple (and correct) way to get the desired output using string.Format and without entering any new variables.
source share