Why i can not save list in c# list? -
i'm new in c#
, write class:
public class manager { public string versionname { get; set; } public double value { get; set; } }
, use this:
list<manager> lstsummary = new list<manager>(); manager summary = new manager(); summary.versionname = "12"; summary.value =12; lstsummary.add(summary); summary.versionname = "13"; summary.value = 19; lstsummary.add(summary);
code save latest class record ,means save versionname=13 , value=19
,how can solve problem?thanks.
you have re-instantiate summary
variable so:
manager summary = new manager(); summary.versionname = "12"; summary.value =12; lstsummary.add(summary); summary = new manager(); // <-- add summary.versionname = "13"; summary.value = 19; lstsummary.add(summary);
Comments
Post a Comment