How to check if my string only numeric

后端 未结 7 2050
臣服心动
臣服心动 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);
    }
    

提交回复
热议问题