C# String 找字元[正找/反找] +字串切割(分割)
C# String 找字元[正找/反找] +字串切割(分割)
資料來源: http://a-jau.blogspot.com/2012/01/cstringindexoflastindexofsubstringsplit.html
正找
String.IndexOf
反找
String.LastIndexOf
Ex:
String StrBuf = System.Text.Encoding.Default.GetString(byBuf);//SY630NT2-SV6V511 if(StrBuf.LastIndexOf('V')>0) { blnAns = true; m_StrV5ControllerModel = StrBuf.Substring(0, StrBuf.LastIndexOf('V'));//SY630NT2-SV6 m_StrV5ControllerVersion = StrBuf.Substring(StrBuf.LastIndexOf('V')+1);//511 }