使用背景如下
A表 #1字段 储存数据
"1|2013/10/12 12:33:55,2|2013/10/13 08:21:34,3|2013/10/14 19:41:57"
B表 #1 #2字段 储存数据
"1" "A" "2" "B" "3" "C"
为了方便读取,将A表 #1读取切割,随后储存在 List<Model.C>中
public class C { public C(int id,DateTime date) { this.ID = id; this.Date = date; } private int _id; private DateTime _date; public int ID { set { _id = value } get { return _id } } public DateTime Date { set { _date= value } get { return _date } } }
List<Model.C> cList = new List<Model.C>(); if (!string.IsNullOrWhiteSpace(A.#1)) { string[] AList= A.#1.Split(','); for (int i = 0; i < AList.Length; i++) { string[] ALists = AList[i].Split('|'); cList.Add(new Model.C(Convert.ToInt32(ALists[0]), Convert.ToDateTime(ALists[1]))); } }
Model.C cFind = cList.Find(delegate(Model.C cIndex) { return cIndex.ID== B.#1; });