In c programming language,
I can do
printf("%d\n", value);
But in c#, how can I do it? For example string is "Good %s everybody"
I want to replace %s with the variable. Are there any solution except for
str.Replace("%s","good morning");
string.Format
would be your function of choice.
You then could write e.g.:
const string t = "Thomas";
var s = string.Format("Good morning {0}.", t);
With {0}
being replaced with the value of t
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With