I am new to programming.. and I was not able to find the solution for the string[] Index was outside the bounds of the array solutions..- Can anyone explain, what in the below code is wrong. What would be the right way of declaring an array and limiting it dynamically?. Will it be fine to do so? -
I want to get the values of the array in the FOR loop - like TOkenlist[]={1,2,3}
but I am trying to do in FOR LOOP
Tokenlist[0] = "1";
Tokenlist[1] = "2";
Tokenlist[2] = "3";
//MY CODE FOLLOWS
string[] Tokenlist;
string[] MassageTokenList;
if (!(Convert.ToInt16(val_PhysioNumber.Text) == 0))
{
for (i=1; i <= Convert.ToInt16(val_PhysioNumber.Text); i++)
{
Tokenlist = new string[i];
SqlCommand cmd = new SqlCommand("ClinicalInvoicing", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@name", txt_NameClinical.Text);
cmd.Parameters.AddWithValue("@natID", txt_NatIDClinical.Text);
cmd.Parameters.AddWithValue("@memberType", MemType);
cmd.Parameters.AddWithValue("@serviceType", 1);
string Token = cmd.ExecuteScalar().ToString();
if (Token != "")
{
Tokenlist[i] = Token;
}
}
}
any help will be highly appreciated