拆分字符串
拆分一个字符串,获取每一组的key与value。
如字符串:
"qq=adf;f=qewr98;eer=d9adf;t=ad34;f=qewrqr;u=adf43;gggg=2344"
class Bf { public string Key { get; set; } public string Value { get; set; } public Bf() { } public Bf(string key, string value) { this.Key = key; this.Value = value; } public override string ToString() { return string.Format("key:{0},value:{1}", this.Key, this.Value); } }
这个是对物件对象,有key和value两个特性。
我们需要把拆分好的数据临时存储起来,现在我们把它们存放在一个List<T>集合中:
class Bg { private List<Bf> _list = new List<Bf>(); public void Add(Bf bf) { _list.Add(bf); } public virtual IEnumerable<Bf> Bfs { get { return this._list; } } }