You can put the values in an array, then you can access them by index:
public DataTable Add_new(string t1,string t2,string t3,string t4,string t5,string t6,string t7,string t8,string t9,string t10) {
string[] t = { t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 };
OleDbParameter[] param = new OleDbParameter[10];
for (int i = 1; i < 11; i++) {
param[i-1] = new OleDbParameter(i.ToString(), OleDbType.VarChar);
param[i-1].Value = (t[i - 1]);
}
DataTable dt = new DataTable();
dt = DAL.selectdata("Add_Code", param);
return dt;
}
Another approach is to turn the parameters into a params array. You call it the same way, but it is an array when it arrives:
public DataTable Add_new(params string[] t) {
if (t.Length != 10) throw new ArgumentsException("The method should be called with 10 parameters.");
OleDbParameter[] param = new OleDbParameter[10];
for (int i = 1; i < 11; i++) {
param[i-1] = new OleDbParameter(i.ToString(), OleDbType.VarChar);
param[i-1].Value = (t[i - 1]);
}
DataTable dt = new DataTable();
dt = DAL.selectdata("Add_Code", param);
return dt;
}
Note: Those values that you send into the method probably has some meaning. You should consider to have meaningful names for the parameters, and perhaps just write the code for creating ten parameters. Having a loop doing it is convenient, but it's not very easy to maintain.