Specify decimal places using variables inside string interpolation
问题 I have a string format which includes two integer variables, each of which needs to be formatted to a variable length: int x = 1234; int y = 42; // Simplified, real values come from method outputs, so must use the variables: int xFormatDigitCount = 7; int yFormatDigitCount = 3; var xStringFormat = new string('0', xFormatDigitCount); // "0000000" var yStringFormat = new string('0' ,yFormatDigitCount); // "000" For now I only managed to get the desired format using the integer variables'