且构网

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

如何检查字符串是否包含从 a 到 z 的任何字母?

更新时间:2023-02-26 12:17:40

用这个替换你的 for 循环:

errorCounter = Regex.Matches(yourstring,@"[a-zA-Z]").Count;

记得使用 Regex 类,你必须在你的导入中使用 System.Text.RegularExpressions;

Remember to use Regex class, you have to using System.Text.RegularExpressions; in your import