Adding variable in message output?Solved
Hey guys. My question is as follows...  I want to add both string and int into reply and I know it can be done this way:

[ConsoleCommand("test")]
        void cmdTest()
        {
            string name = "Jack";
            int age = "25";
            Puts("Name is " + name + " and age is " + age");
        }​


But is there a way how to do it this way? (currently gives "error CS0029: Cannot implicitly convert type `string' to `int')...
[ConsoleCommand("test")]
        void cmdTest()
        {
            string name = "Jack";
            int age = "25";
            Puts("Name is {0} and age is {1}", name, age);
        }​
Age is int, you need string. Try using Puts($"Name is {name} and age is {age}");
This will work
Omg I had int value in quotes... how did I miss that??? Thanks misticos.
There's the string interpolation method (provided by C#, not Puts) as suggested above:

Puts($"Name is {name} and age is {age}");​


Or the more explicit C# way with string.Format:

Puts(string.Format("Name is {0} and age is {1}", name, age));


Or like you already have, with the addition of .ToString():

Puts("Name is " + name + " and age is " + age.ToString());
Thanks Wulf. :)
Locked automatically