String "format"?
Hi!
Instead of "formatting" a string like this:
string info = name + "costs" + price + " $";
I remember some time ago I came across a string, that looked something like this:
string info = "{0} costs {1} $"; (where {0} was a string and {1} was a float, and it became "Car costs 10 $")
If anyone understands what I'm talking about, how do you set this alternate way of doing it up?
Answer by Dave-Carlile · Jul 24, 2013 at 05:58 PM
Note: $$anonymous$$icrosoft also calls that composite formatting: https://docs.microsoft.com/en-us/dotnet/articles/standard/base-types/composite-format
Answer by sawalls · Feb 03, 2018 at 08:05 PM
As of Unity 5.0 there's a new function in Debug just for this, Debug.LogFormat, similar to Console.WriteLine in .NET:
Debug.LogFormat ("Test: {0}", 10);
Your answer
Follow this Question
Related Questions
\n Not picked up when reading string from file's name 1 Answer
how to read string from an IP address? 0 Answers
I need help with calling a string 1 Answer
Convert keycode to string 1 Answer
is there an efficient way to compare tags in code ? 0 Answers