C# testing to see if a string is an integer?

后端 未结 10 1415
北恋
北恋 2020-11-28 12:00

I\'m just curious as to whether there is something built into either the C# language or the .NET Framework that tests to see if something is an integer

if (x         


        
10条回答
  •  情歌与酒
    2020-11-28 12:25

    its simple... use this piece of code

    bool anyname = your_string_Name.All(char.IsDigit);
    

    it will return true if your string have integer other wise false...

提交回复
热议问题