I have data table with column "Subject", row 1 [subject] column in data table "ABC / Vesse / 11371503 /C report " row 2 [subject] column in data table "Value/BEY/11371503/A report" I need to compare the values inside subject column based on / and if the value before / is same,i should look for next value before next slash and sort..
As suggested, I'm splitting based on /
strSubSplit. Can please help how to sort and add to the list after comparing. Thanks a lot.
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow row in ds.Tables[0].Rows)
{
string strSubject = row["Subject"].ToString();
string strEmailFrom = row["EmailFrom"].ToString();
string strEmailTo = row["EmailTo"].ToString();
string strEmailCC = row["EmailCc"].ToString();
string strEmailContent = row["EmailContent"].ToString();
// Do proper error handling here
DateTime strCreatedOn = DateTime.Parse(row["CreatedOn"].ToString());
string[] strSubSplit= row["Subject"].ToString().Split(new[] {'/'},StringSplitOptions.RemoveEmptyEntries);
mailInfoList.Add(new Tuple<string, string, string, string, string, DateTime>(strSubject, strEmailFrom, strEmailTo, strEmailCC, strEmailContent, strCreatedOn));
var newList = mailInfoList.OrderBy(x => x.Item1).ThenBy(x => x.Item6).ToList();
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…