Extract version number from string(eg : “ver.1.9.0”)

后端 未结 3 563
盖世英雄少女心
盖世英雄少女心 2021-01-29 05:19

if i pass a string (verstring == \"vername.1.19.5\") it will return the version because i am ignoring Currentver[0]. if i want to pass verstring == \"1.19.5\".

I mean i

3条回答
  •  盖世英雄少女心
    2021-01-29 06:05

    Why making life harder as it already is?

    string v = verstring.Replace(':','.').Substring(5,verstring.Length);
    

    Now you don't need to care about whether it actually is separated by : or . you can simply split by .:

    currentVer = v.Split('.');
    a= Convert.ToByte(currentVer[1]);
    b= Convert.ToByte(currentVer[2]);
    c= Convert.ToByte(currentVer[3]);
    

提交回复
热议问题