jeudi 12 mars 2015

transferring hard coded data to arrays

Okay so I would like to ask for people's advice on how to improve my code, there are no problems with it, I feel weird coming onto this site not having problems with code.


Currently, my code is lacking complexity, it is hard code by definition, I want to know if there are ways that I can reduce hard code by transferring the data into arrays or loops.


I have some of my code here I think a small snippet shall suffice.



MySqlDataAdapter dAdapter = new MySqlDataAdapter(pQuery, Connection);
dAdapter.Fill(dTable);
dAdapter.Dispose();
int One, Two, Three;
One = Convert.ToInt32(dTable.Rows[0]["Cost"].ToString());
Two = Convert.ToInt32(dTable.Rows[1]["Cost"].ToString());
Three = Convert.ToInt32(dTable.Rows[2]["Cost"].ToString());


Of course ignore the pQuery and Connection. I feel like I'm taking the 'long way around' whereas I'm sure there is a cleaner way of doing this.


Any suggestions?


Aucun commentaire:

Enregistrer un commentaire