要在字符串中查找数字,请使用正则表达式。我们已设置正则表达式模式以从字符串中获取数字。Regex r = new Regex(@"\d+");现在,使用 C# 中的 Match 类设置字符串。Match m = r.Match("Welcome! We are open 365 days in a year!");现在使用 Success 属性显示结果,如果在字符串中找到数字,如下面的完整代码所示 -示例 Live Demo使用 System; 使用 System.Text.RegularExpressions; 类演示 { 静态无效主() { Regex r = new Regex(@"\d+"); Match m = r.Match("Welcome! We are open ... 阅读更多