I have following code in my programm:
string[] strarray = new string[] {bird, lion, ape};
Array.Reverse(strarray);
strarray.Reverse();
foreach(var value in strarray)
{
Console.Write(value.ToString());
}
I want the Array "strarray" to be surrounded like that Array[ strarray ]. I cant use the string.Format here because it loops through it and with each string the text Array[ ... ] gets added. How should I do here?
Try this:
string[] strarray = new string[] { "bird", "lion", "ape" };
Console.Write($"Array[{String.Join(", ", strarray.Reverse())}]");
That gives me:
Array[ape, lion, bird]