Stringbuilder printing "System.Collections.Generic.List" instead of the string item in the list, why?

Hello!^^ Im currently trying to take all parametres from an object(they are all strings) and pass onto a single string.
To do this i create 3 lists, the first is where all my objects are added, the second is one i use to add all the parametres from a single object from the first list. The second list only hold the parametres of 1 object at a time. When it has all the parametres of the single object it passes them on to my third and final list(and then clears itself) which is the list i want printed with my stringbuilder. If the objects in my first list only contain 1 string, it works just fine, but when the objects has several parametre values the stringbuilder result of the third list returns this : “System.Collections.Generic.Listxxx” instead of the string item in the list, why?

Here is some of the code:

// Line number: // Product: Price: Start-date: End-date: Where: Note: Tipped-by:

// First. All table items get thrown inhere for easier breaking up of their data                                                                                  
  private List<aTableRow> allTableRows = new List<aTableRow>();

  // Second. Used to store the data for only a single table row at a time
  private List<string> singleTableRowValues = new List<string>();

  // Third. Final list with all the sorted strings of all table rows
  private List<string> finalList = new List<string>();

public void SetTableContent()
StringBuilder builder = new StringBuilder();

// Take all objects from the list allTableRows individually and place all the items values in its own list, making it possible to string all the single items datavalues together with a stringbuilder.
foreach (var tableRow in allTableRows)

    builder.Append(singleTableRowValues).Append(" - ");

    tableContent = builder.ToString();


    // Cleans up the converter list and table content so they are ready to convert next item.
    tableContent = "";

foreach (var preparedItem in finalList)
    builder.Append(singleTableRowValues).Append(" - ");

    allTableContent = builder.ToString();


(allTableContent is the string used to display the combined strings to the screen.)

ToString() method returns a string representation of the object. Hence “System.Collections.Generic.Listxxx”.

Is builder a stringbuilder and is allTableContent a string?

Yes to both, sorry if theres a comepletely obvious answer here but im rather new programmer and just trying to learn by myself :stuck_out_tongue:

Do i have to convert the builder to a string or something? I actually thought it was that already, i mean i had no problem printing a whole list of different strings this way. Just the issue comes when the objects in the lists are no longer strings.

This should fix it… need to put each item in there as a string
You were putting the whole list in there instead of the iterator item :wink:

Oh lol cant belive i missed that one :smiley: It didnt fix it though it was indeed an error on my part. I still get the Ssystem.Collections.Generic.List printed unfortunatly :confused:

I am pretty sure this line is not going to add strings into the builder. It will just add the string interpretation (“System…”) to string builder.

you may want something like

foreach (string s in singleTableRowValues)

Hmm you might be onto something here, i got it to print some of the actual values now, thanks alot im gonna loook into this further! :smiley: