foreach (char chr in input)
{
//检查字母
if (char.IsLetter(chr))
{
countLetters++;
}
//检查数字
if (char.IsDigit(chr))
{
countDigits++;
}
//检查标点
if (char.IsPunctuation(chr))
{
countPunctuation++;
}
}
foreach (char chr in input)
{
//检查字母
if (char.IsLetter(chr))
{
countLetters++;
}
//检查数字
if (char.IsDigit(chr))
{
countDigits++;
}
//检查标点
if (char.IsPunctuation(chr))
{
countPunctuation++;
}
}
转载于:https://www.cnblogs.com/pnljs/archive/2011/10/12/2208375.html