I tried to migrate a line of code that uses String.Format
twice to the new .NET Framework 6 string interpolation feature but until now I was not successfull.
var result = String.Format(String.Format("{{0:{0}}}{1}",
strFormat, withUnit ? " Kb" : String.Empty),
(double)fileSize / FileSizeConstant.KO);
A working example could be:
var result = String.Format(String.Format("{{0:{0}}}{1}",
"N2", " Kb"), 1000000000 / 1048576D);
which outputs: 953,67 Kb
Is that possible or do we need to use the old construct for this special case?
strFormat
). Although it could be simplified as Mario suggests to make it more readable. – Oxysalt