I need to save my List<Cupon> to a text file. I am using this code:
File.WriteAllText(@"C:\Users\urim.sadiku\Desktop\Loja.txt", Cupo.ToString());
List<string> myList = new List<string>(Cupo.ToString().Split(','));
but the output in txtFile is:
System.Collections.Generic.List`1[LojeShperblyese2.Coupon]
Note : I need to save with Split(), but I don’t know how to do that.
What do I need to do to save my list correctly?
By default,
ToStringmethod return type name, if it is not overriden in subclass.Try to use
This assumes, that you have implemented
ToStringmethod corrrectly on yourLojeShperblyese2.Couponclass