This questions really isn't hard to understand. I have always wondered this and wondered if possible, how could it be done. Well this is sort what I'd like to do if possible:
int number = 50;
string text = "The number is %number";
Where I wrote %number in the string
above, I would like the value of number
to be inserted into the string
, because the way I would usually go about doing something like this would be like:
int number = 50;
string text = "The number is " + number.ToString();
Which yes, the way I integrated number
into the string
above is an okay way of doing so, but I have always wondered, is it possible to do something such as the first example I wrote, where to put a value of an object
into a string
all you would have to do is write some type of character
or string
(used to reference the object
), along with the name of the object
into a string
to get a result of a string
with the value of the object
in it? Or is there anything sort of like this you're able to do?