对于SName
和Email
字符串数组,都没有必要得到相同的长度。
Index is out of bound because length are not same
。
更好的办法是单独做到这一点:
string[] SName = Request.Form.GetValues("title");
string[] Email = Request.Form.GetValues("fname");
for (int i = 0; i < SName.Length; i++)
Response.Write(SName[i]);
for (int i = 0; i < Email.Length; i++)
Response.Write(Email[i]);
如果你想print one name and email
然后使用此:
string[] SName = Request.Form.GetValues("title");
string[] Email = Request.Form.GetValues("fname");
int iLength = -1;
if(SName.Length > Email.Length)
iLength = SName.Length;
else
iLength = Email.Length;
for (int i = 0; i < iLength; i++)
{
if(i < SName.Length)
Response.Write(SName[i]);
if(i < Email.Length)
Response.Write(Email[i]);
}
注意:
如果你不处理数组具有相同名称的HTML元素,则不必使用Request.Form.GetValues("title")
。见下面的例子:
string SName = Request.Form["title"];
string Email = Request.Form["fname"];
Response.Write(SName + " " + Email);
'为(INT I = 0; I
bumbumpaw