将多付款方式结账所拼接的字符串转化成Hashtable,字符串格式如 21|122;21|;22|12;22|12.2等。
代码如下:
////// 将多付款方式结账所拼接的字符串转化成Hashtable/// 字符串格式如 21|122;21|;22|12;22|12.2/// /// ///public Hashtable GetPayType(string str){ Hashtable hashtable = new Hashtable(); string[] s1 = str.Split(';'); foreach (string s in s1) { string[] s2 = s.Split('|'); if (hashtable.Contains(s2[0])) { hashtable[s2[0]] = Convert.ToDecimal(hashtable[s2[0]]) + Convert.ToDecimal(s2[1] == "" ? "0" : s2[1]); } else { hashtable[s2[0]] = s2[1] == "" ? "0" : s2[1]; } } return hashtable;}