4
Example:
string x;
string[] y = {"5", "0","0","5","5"};
x = "50055"
I want to put it all together into one variable. I will store in a variable not print.
4
Example:
string x;
string[] y = {"5", "0","0","5","5"};
x = "50055"
I want to put it all together into one variable. I will store in a variable not print.
7
Only use the Join
string[] y = {"5", "0","0","5","5"};
string x = string.Join("",y);
Console.WriteLine(x);
Check on . Netfiddle: https://dotnetfiddle.net/4exn35
Documentation: https://msdn.microsoft.com/pt-br/library/57a79xd0(v=vs.110). aspx
2
You can use the String.Join
when you need a separator. So:
string[] nomes = {"Vinicius", "Rovann", "Anderson"};
return string.Join(";", nomes);
// Saída: "Vinicius;Rovann;Anderson"
If you want to concatenate an array of strings into a single string, you can use String.Concat
. Behold:
string[] arr = {"1", "2", "3"};
return string.Concat(arr);
// Saída: "123"
Browser other questions tagged c#
You are not signed in. Login or sign up in order to post.