C#C
C#3y ago
15 replies
Bored Student

Neat String interpolation

foreach(file in files){
//Process file
Console.WriteLine($"Processed File [{file.Nr}/{files.Count}]");
}

I have this little something, and I want the counter to stay fixed width so
[ 1/50]
instead of
[1/50]
how can I do this ?
As simple as possible, I just want it to look neat not write a TUI framework.

I found
$"{val , fixedWidth}"
but that only works with constants so it can't adapt if I reach 100 files.
Was this page helpful?