如果我有这样的字符串:
string a = "<=1.0.5" or "=1.0.5" or "!=1.0.5";
如何将带有运算符的零件和带有版本号的零件分别转换为变量?
答案 0 :(得分:1)
如果字符串中始终存在相等的运算符:
string a = "<=1.0.5"; // "=1.0.5" or "!=1.0.5" or "==1.0.5"
int indx = a.LastIndexOf('=') + 1;
string op = a.Substring(0, indx); //<=
string version = a.Substring(indx); //1.0.5