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)
{
singleTableRowValues.Add(tableRow.Product.ToString());
singleTableRowValues.Add(tableRow.Price.ToString());
singleTableRowValues.Add(tableRow.StartDate.ToString());
singleTableRowValues.Add(tableRow.EndDate.ToString());
singleTableRowValues.Add(tableRow.Where.ToString());
singleTableRowValues.Add(tableRow.Note.ToString());
singleTableRowValues.Add(tableRow.TippedBy.ToString());
builder.Append(singleTableRowValues).Append(" - ");
tableContent = builder.ToString();
finalList.Add(tableContent);
// Cleans up the converter list and table content so they are ready to convert next item.
singleTableRowValues.Clear();
tableContent = "";
}
foreach (var preparedItem in finalList)
{
builder.Append(singleTableRowValues).Append(" - ");
allTableContent = builder.ToString();
}
}