我得到以下代碼的錯誤:在這裏,我的pagedata.length是495,並且我在變量k中使用了其中的57個。索引超出了數組字符串的範圍
for(int k = 0; k < pagedata.Length;k++)
{
string[] textdata = pagedata.Split(new char[0]);
string stringforemail = textdata[k];
if (stringforemail.Contains("@") && stringforemail.Contains("."))
{
TableRow tr = new TableRow();
//tr.BorderStyle = BorderStyle.Solid;
TableCell tc = new TableCell();
tc.BorderStyle = BorderStyle.Solid;
tc.Text = stringforemail;
tr.Cells.Add(tc);
Table1.Rows.Add(tr);
}
}
因爲我的代碼中有錯誤,但我無法弄清楚錯誤..請幫我理解錯誤。
謝謝
什麼長度是文本數據[]? – jbutler483 2014-08-29 12:20:34
顯然你的循環一直運行到'pagedata.Length',但是它比'pagedata.Split(new char [0])更高,length' - textdata [k]超出了界限。 – 2014-08-29 12:20:35
我們無法真正幫助您。 Pagedata.Length> Split.NewChar.Length,因此您在尋找的內容不一致。正則表達式可能會有所幫助。 – DidIReallyWriteThat 2014-08-29 12:23:34