[英]Parsing the string in C#
"Vitrek.Inc,V63,0,FW2.06"
是我擁有的字符串,現在我想解析它以僅在 C# 中獲得"FW2.06"
。有人可以幫忙嗎?
string firmwareversion = buffer.Trim().Remove(0, 17);
試過這個,但得到它前面的空白
這個應該有幫助
string temp = "Vitrek.Inc,V63,0,FW2.06";
string[] tempSplit = temp.Split(',');
string wordIwant = (tempSplit[tempSplit.Count()-1]).Trim();
它應該可以解決您的問題。 下次你需要更具體。 例如:“當我拆分字符串時,我需要得到最后一個單詞”
string firmwareversion = buffer.Substring(buffer.LastIndexOf(',')+1).Trim();
LastIndexOf
查找string
最后一個逗號的索引
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.