How can I get the Debug to print the values of a variable?

I am new to unity and I’m creating a game with multiple weapons to switch between each other. To check this code I made the program such that when i press a key a number will be incremented or decremented to give me the new weapon number by which I can switch between them. To test if my code is working properly I tried to create a Debug.Log() which could show the Number in the variable WeaponNum when I pressed the button. However, unity gives a compiler error to the code I put in, which was,

Debug.Log("WeaponNum = " WeaponNum);

Can anyone please help me with this please.

Debug.Log("WeaponNum = " + WeaponNum);
Debug.Log("WeaponNum = " + WeaponNum.ToStiring());
Debug.Log(string.Format("WeaponNum = {0}", WeaponNum));

Not sure when it was added, but you can also currently do…

Debug.LogFormat("WeaponNum = {0}", WeaponNum);

And, if you’re on C# language version 6 (or greater), you could do an interpolated strings statement like this…

Debug.Log($"WeaponNum = {WeaponNum}");

Yup works like a charm thanks

Didn’t work for me