即時通訊在我的代碼在C#中有麻煩。我想分割沒有固定值的字符串。這裏'我的代碼請幫我解決這個問題。如何拆分多個字符串
protected void GridViewArchives_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView drView = (DataRowView)e.Row.DataItem;
Literal litAuthors = (Literal)e.Row.FindControl("ltAuthors");
string authors = drView["Author(s)"].ToString();
//authors = Trent Riggs:[email protected]|Joel Lemke:[email protected]
string[] splitauthors = authors.ToString().Split("|".ToCharArray());
foreach (string authornames in splitauthors)
{
litAuthors.Text = string.Format("{0}<br /><br />", authornames);
}
}
}
問題IM面對這裏是當我呈現頁面它只顯示一個字符串值,並且不顯示在陣列中的隨後的字符串。
用「|」分割字符串後, delimeter我想用名稱和電子郵件地址與分隔符「:」分割字符串。我該怎麼做呢?