0
運行下面的代碼時,我得到一個運行時異常fix:Index
是數組的邊界之外的範圍之外:修復:索引數組的
char[] delim = { ' ' };
string sContent = txtcontent.Text;
string sFind = txtfind.Text;
string sReplace = txtreplace.Text;
string sRecontent = txtrepalcecontent.Text;
//Session["find"] = sFind;
string[] fileLineString = new string[sContent.Length];
for (int i =0 ; i < sContent.Length; i++)
{
//fileLineString[0] = sContent[0].ToString();
string[] content = sContent.Split(delim);
if (sFind == content[i]) ////**error**
//if (Session["find"].ToString() == content[i])
{
string A = sContent.Remove(i, txtfind.Text.Length);
string S = A.Insert(i, sReplace);
txtrepalcecontent.Text = S;
}