Reputation: 159
i have a method
public string[] getlist()
{
-----
-----
Return Result.toString();
}
How do i call this method in my main method and show all the list using
console.write(result)
in loop
Thanks
Upvotes: 2
Views: 4462
Reputation: 81
Obviously that method is incorrect as it's trying to return a string instead of an array.
However assuming myObject is an instance of what ever Object type has this method.
foreach(string str in myObject.getlist())
{
Console.WriteLine(str);
}
Upvotes: 1
Reputation: 66388
Simple Join()
will do the work just fine no need in loop:
Console.Write(string.Join(", ", myObj.getList()));
Upvotes: 2
Reputation: 1911
use a foreach (var result in retrivedString) {Console.Write(result);}
Upvotes: 1