就是按下“分析”按鈕后,統計編輯框1的文字并在編輯框2輸出:此段文字中有中文x個,英文x個,數字x個。
uj5u.com熱心網友回復:
string s = "abcd45612,asd";int characters = 0;
int numbers = 0;
int symbols = 0;
foreach (char c in s)
{
if ((c >= 33 && c <= 47) || (c >= 58 && c <= 64) || (c >= 91 && c <= 96) || (c >= 123 && c <= 126))
symbols++;
if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122))
characters++;
if (c >= 48 && c <= 57)
numbers++;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/102581.html
標籤:基礎類
