Class List Keeps Printing Out As Class Name In Console?

前端 未结 4 756
北荒
北荒 2020-11-27 09:02

Ok, so maybe I\'m just tired or something but I can\'t seem to figure out why this keeps happening.

The code below is called every day for a data point in a database

4条回答
  •  猫巷女王i
    2020-11-27 09:31

    C# doesn't know anything about the SharePrices other than the class name. If you want it to display something specific, you will need to override the ToString() method like so:

    public override string ToString()
    {
        return "SharePrice: " + theDate.ToString() + ": " + sharePrice.ToString();
    }
    

    Of course, you can format it however you like, that is the beauty of it. If you only care about the price and not the date, only return the sharePrice.

提交回复
热议问题