How to check if my string only numeric

后端 未结 7 2026
臣服心动
臣服心动 2020-12-18 17:49

How I can check if my string only contain numbers?

I don\'t remember. Something like isnumeric?

相关标签:
7条回答
  • 2020-12-18 18:50
    public bool IsNumeric(string str)
    {
        return str.All(c => "0123456789".Contains(c);
    }
    
    0 讨论(0)
提交回复
热议问题