I am coding in Unity3D in C#, and when printing or using debug statements or console statements, I have always used something like this:
Debug.Log("The sum of these two variables is :" + SumOfVariables);
However, I am going through a new book to try and learn to be a better programmer, and they often use this instead:
Debug.Log("The sum of these two variables is {0}", SumOfVariables);
I assume it doesnt matter either way, but is there an advantage of using the later? Also, for anyone that uses unity, I am getting an error message when I try to use it that way, but it works fine when I use the first method. It says basically that Debug.Log doesnt have a parameter for that. And also that I cant convert a string expression to type UnityEngine.Object. The variable I am using is a String Property of a class.
My question is less about the unity peice and more about which is better. But for extra credit if you want to tell me why I get that error that would be great. I am sure this has been asked before, but I was getting all kinds of different topics when I tried to search, so I apologize in advance, thanks for answering!!