CSharp · Console
//@nuget: FormatWith
using FormatWith;
public class Program
{
public static readonly System.Decimal LeftPadTestValue = 1234.56M;
public static readonly System.String LeftPadTestFormat = "'{LeftPadTestValue,15:#,##.00}'";
public static readonly System.String LeftPadTestFormatComposite = "'{0,15:#,##.00}'";
public static readonly System.String ExpectedValue = "' 1,234.56'";
public static void Main()
{
System.Collections.Generic.Dictionary<System.String, System.Decimal> replacementDictionary = new System.Collections.Generic.Dictionary<System.String, System.Decimal>()
{
{"LeftPadTestValue", LeftPadTestValue}
};
System.Console.WriteLine($"'{LeftPadTestValue,15:#,##0.00}'");
System.Console.WriteLine(System.String.Format(LeftPadTestFormatComposite, LeftPadTestValue));
//These all produce this error: Unhandled exception. System.Collections.Generic.KeyNotFoundException: The parameter "LeftPadTestValue,15:#,##.00" was not present in the lookup dictionary
//System.Console.WriteLine(LeftPadTestFormat.FormattableWith(replacementDictionary));
//System.Console.WriteLine(System.String.Format(LeftPadTestFormat.FormattableWith(replacementDictionary).ToString(), LeftPadTestValue));
//System.Console.WriteLine(LeftPadTestFormat.FormatWith(replacementDictionary));
}
}