Because you test it wrong. In thise 2 lines:
String.Format(test,number);
string res=test;
String.Format
returns a string. As can be seen in the documentation And this new string is the composed string with your number that you expect. If you assign the format string test
to res
and check whether string res
has now the desired output. You will (of course) not find it but only
“add number here {0}”;
You need to use the return value of the method String.Format
. There you will find the desired output:
string res = String.Format(test,number);
Console.WriteLine(res);