编写代码,由用户输入一个字符串,使用foreach循环遍历出此字符串中有多个字母,多少个数字,多少个标点

  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/p/2208375.html