I have written a simple code and have passed an array to the method and have returned the value and trying to get it printed. Somehow, I am not getting the required output. Please point out where I got wrong. Also tips to make the code concise are most welcome.
static void Main(string[] args)
{
string[] ar = new string[] { "hello", "world", "people" };
writeString(ar);
Console.WriteLine(ar);
Console.ReadLine();
}
static string writeString(string[] ar)
{
string a1 = " ";
foreach (string a in ar)
{
a1 = a1 + a;
}
return a1;
}
writeStrings returnwriteStringshould write string - meaning it should be writing to console instead of returning result...writeStringConsole.WriteLine(writestring(ar));