Remember that strings are
immutable
- once created they cannot actually be changed. Every time you try to change a string, what you actually do is create a new string.
So if you use
number
as a template instead of replacing it each time:
private static string number = @"//10.0.0.ZZ";
for (int i = 1; i < 4; i += 1)
{
string IP = number.Replace("ZZ", $"{i.ToString()}");
Console.WriteLine(i);
Console.WriteLine("number: " + IP));
}
Or better
private const string number = @"//10.0.0.ZZ";
for (int i = 1; i < 4; i++)
{
string IP = number.Replace("ZZ", i.ToString());
Console.WriteLine(i);
Console.WriteLine($"Number: {IP}");
}