c# - How to use Substring , to return an integer of all the values after the first char -
i have string assetnumber have following format c100200. need folloiwng:-
get characters after first (e.g. 100200 using above example)
convert substring integer
return integer + 1
but not know how use sub-string characters after first char, , how convert string int? on appreciated.
var result = int32.parse("c100200".substring(1)) + 1;
if have default value, if can't parse current string:
int result; if (!int32.tryparse("sdfsdf".substring(1), out result)) { result = 42; } result+=1;
Comments
Post a Comment