Dictionary<string, string>拆分字串
阿新 • • 發佈:2021-11-29
private Dictionary<string, string> GenDictionary(byte[] inMsg) { Dictionary<string, string> dictionary = new Dictionary<string, string>(); string arg= Encoding.Default.GetString(inMsg); char[] trimChars = new char[1]; string text = arg.TrimEnd(trimChars); string[] array = text.Split(new char[] { ';' }); for (int i = 0; i < array.Length; i++) { string text2 = array[i]; if (!string.IsNullOrEmpty(text2) && !dictionary.ContainsKey(text2.Split(new char[] { ':' })[0])) { dictionary.Add(text2.Split(new char[] { ':' })[0], text2.Replace(text2.Split(new char[] { ':' })[0] + ":", "")); } } return dictionary; }
本文來自部落格園,作者:農碼一生,轉載請註明原文連結:https://www.cnblogs.com/wml-it/p/15618324.html
技術的發展日新月異,隨著時間推移,無法保證本部落格所有內容的正確性。如有誤導,請大家見諒,歡迎評論區指正!
個人開原始碼連結:
GitHub Gitee GitLab
開發學習交流群: