2
I’m doing an old-fashioned game, where there’s a function that prints it, and another that contains the 9 playable positions, I simplified the code so it doesn’t get too big and I just put a position.
There is a possibility of doing the same console.writeline, where we put the index and at the end of the string we put the variable?
private static char[] posJogaveis = { '_' };
public static string[] updateVelha()
{
string[] structVelha = { " _{0}_", posJogaveis[0].ToString() };
return structVelha;
}
private static string[] structVelha = updateVelha();
The idea was to change positions, but this method doesn’t exist or I’m doing it the wrong way:
So in the end I don’t need to say which variable it is, just put it in the string exactly as you did?
– Josias Matheus
Yes, by interpolation you do nothing at the end, you really put the variables where they should be as I put example. And you don’t need Tostring, it’s redundant.
– Kevin Kouketsu
Just a reminder that string interpolation is only available from C#6 onwards.
– Ronaldo Araújo Alves
Really, I forgot the detail of the version and also was not specified by the author, but I will add anyway.
– Kevin Kouketsu