I just found a good example in which \0
is very important and necessary.
Assume we want to remove the last unwanted ,
in the following code.
for (int i = 0; i < 5; i++)
{
foreach (var a in "Money")
Console.Write($"{a},");
}
If we only add Console.Write("\b\n");
as follows,
for (int i = 0; i < 5; i++)
{
foreach (var a in "Money")
Console.Write($"{a},");
Console.Write("\b\n");
}
The output will be still the same.
But if we add \0
as follows,
for (int i = 0; i < 5; i++)
{
foreach (var a in "Money")
Console.Write($"{a},");
Console.Write("\b\0\n");
}
The unwanted trailing ,
vanishes.
this.TestSaveString("\0");
– Porcupine