I'm very new to programming so this probably is a silly question for the most of you, but still and since I have already tried to look in Google, here it goes :
I created a class with some properties and 2 methods, some of the properties should be for the first method and the other for the second method.
both of the methods returns a list and my problem is that both of the lists returns all of the properties. Don't know why since I'am not using all of them in both methods... here is a example:
class orders { public string invoiceID { get; set; } public string employee { get; set; } public string store { get; set; } public string client { get; set; } public string invoiceDate { get; set; } public string total { get; set; } public string totalYear { get; set; } public string year { get; set; } public static List<orders> getOrders() { string sSQL = "bla bla bla huge query " DBConnect connect = new DBConnect(); DataTable dt = new DataTable(); dt = connect.getBD(sSQL); List<orders> o = new List<orders>(); for (int i = 0; i < dt.Rows.Count; i++) { orders ord = new orders(); ord.invoiceID = dt.Rows[i]["invoiceid"].ToString(); ord.employee = dt.Rows[i]["empname"].ToString(); ord.store = dt.Rows[i]["storename"].ToString(); ord.client = dt.Rows[i]["clientname"].ToString(); ord.invoiceDate = ((DateTime)dt.Rows[i]["invoicedate"]).ToString("dd-MM-yyyy"); ord.total = dt.Rows[i]["total"].ToString(); o.Add(ord); } return o; so in this method I am not using the public properties year and totalYear, but they still appear in the list :(
What am I doing wrong ?
Thank in advance and sorry for the noob question.
UPDATE 1 (second method)
public static List<orders> getTotalYearInvoices() { DateTime date = DateTime.Now; int year = date.Year; List<orders> o = new List<orders>(); for (int i = 2009; i < year; i++) { string sSQL = " another huge query" DBConnect connect = new DBConnect(); DataTable dt = new DataTable(); dt = connect.getBD(sSQL); orders ord = new orders(); ord.year = i.ToString(); for (int j = 0; j < dt.Rows.Count; j++) { ord.totalYear = dt.Rows[j]["total"].ToString(); } o.Add(ord); } return o; }