Console.WriteLine and generic List
Do this:
list.ForEach(i => Console.Write("{0}\t", i));
EDIT: To others that have responded - he wants them all on the same line, with tabs between them. :)
C# Console writeline print out generics list collection
Override ToString():
public class Proto
{
public string name {get;set;}
public Object[] data {get;set;}
public override string ToString()
{
var dataAsString = data.Aggregate(string.Empty, (current, t) => current + t.ToString());
return name + dataAsString;
}
}
And use it
metodo().ForEach(item => Console.Write(item.ToString() + ","));
EDIT:
If you want it as JSON.
Install Json.Net from Nuget for your project and then
metodo().ForEach(item => Console.Write(JsonConvert.SerializeObject(item) + Environment.NewLine));
Unable to print whole list to console
You are trying to print the object directly to console try iterating over list and print them wherever returned.
for (var item in returned)
Console.WriteLine(item)
if using a custom Type. keep in mind that you have defined its to string method.
Related Topics
Differencebetween a Property and a Variable
How to Read Data from a Zip File Without Having to Unzip the Entire File
Value Cannot Be Null. Parameter Name: Source
What Is an MVChtmlstring and When Should I Use It
Make Listview.Scrollintoview Scroll the Item into the Center of the Listview (C#)
How to Get and Set the Window Position of Another Application in C#
Is There Anything Like Asynchronous Blockingcollection<T>
How to Add Claims in ASP.NET Identity
How to Add an Extra Button to the Window's Title Bar
One to One Optional Relationship Using Entity Framework Fluent API
How to Copy Part of an Array to Another Array in C#
Best Way to Display Decimal Without Trailing Zeroes
How to Post Data Using Httpclient
"The Given Path's Format Is Not Supported."
How to Backup and Restore the System Clipboard in C#