更新时间:2022-11-19 08:52:34
int.TryParse
返回一个布尔值,如果成功则返回true,否则返回false.您需要将其包装在if块中,然后使用该逻辑进行操作.
int.TryParse
returns a boolean, true if it succeeded and false if not. You need to wrap this in a if block and do something with that logic.
if(int.TryParse(y, out x))
print (x); // y was able to be converted to an int
else
// inform the caller that y was not numeric, your conversion to number failed
至于为什么不转换您的电话号码,我不敢说,直到您发布了字符串值是什么.
As far as why your number is not converted I could not say until you post what the string value is.