且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么会出现在C#中没有String.IsNumeric功能

更新时间:2022-10-21 21:32:58

The trouble with a method like that would be deciding what counts as "numeric". Should it allow decimals points, should it allow leading whitespace, should it have an upper bound for the number of digits?

Int32.TryParse answers the much more well-defined question of, "is this a valid string representation of an Int32?"

And of course, nothing is stopping you writing your own extension method, that decides if a string is numeric according to your own rules.

相关阅读

技术问答最新文章