GetData returns a List of type Broker, and your Console.WriteLine is reflecting just that; and is working as intended. What You really want to do then is to iterate through that List. And there are a couple of ways of doing this
The first would be in your Main module
static void Main(string[] args) {
List<Broker> BrokerList = GetData();
foreach(Broker b in BrokerList) {
Console.WriteLine(b);
}
}
Another would be to pass this off into another Void
private void DisplayList(List<Broker> bl) {
foreach(Broker b in BrokerList) {
Console.WriteLine(b);
}
}
static void Main(string[] args) {
List<Broker> BrokerList = GetData();
DisplayList(BrokerList);
}
There are other ways you could do this as well... If you wanted to super-encapsulate this you create create a wrapper for the BrokerList and give it it's own ToString() override, which basically would fall back on the same iteration routine
public class BrokerListWrapper {
List<Broker> BrokerList { get; set; }
public BrokerListWrapper(){}
public override string ToString() {
StringBuilder sb = new StringBuilder();
foreach(Broker b in BrokerList) {
sb.AppendLine(b);
}
return sb.ToString();
}
}
So in short... there are a myriad of ways to do what you want, you just need to know what you want and how to make it work via whatever calling method