Console.WriteLine("{0:f4}",c); As in this line, instead of f4 , in place of 4, substitute a variable into which the required number of characters will fall
Console.WriteLine("{0:f4}",c); As in this line, instead of f4 , in place of 4, substitute a variable into which the required number of characters will fall
The first parameter is a regular string, respectively, and you can collect it as you like, using whatever variables you want, starting with the usual concatenation
Console.WriteLine("{0:f"+i+"}",c); Ending with interpolation of strings , which allows you to get away from a direct call to string.Format
Console.WriteLine($"{{0:f{i}}}",c); Console.WriteLine(string.Format("{{0:f{0}}}", i),c); Source: https://ru.stackoverflow.com/questions/636694/
All Articles