网站导航网学 原创论文 原创专题 网站设计 最新系统 原创论文 论文降重 发表论文 论文发表 UI设计定制 论文答辩PPT格式排版 期刊发表 论文专题
返回网学首页
网学原创论文
最新论文 推荐专题 热门论文 论文专题
当前位置: 网学 > 设计资源 > .Net编程 > 正文

C#判断一个字符串中中文和字母或数字的个数

论文降重修改服务、格式排版等 获取论文 论文降重及排版 论文发表 相关服务
  1. int inum=0; 
  2. int ichar = 0; 
  3. int ichi = 0; 
  4. string strTemp; 
  5. for (int i = 0; i < this.textBox1.Text.Length; i++) 
  6.      strTemp=this.textBox1.Text.Substring(i,1); 
  7.      if ("01234567890123456789".IndexOf(strTemp) > -1) 
  8.      { 
  9.           inum++; 
  10.      } 
  11.      else if ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ".IndexOf(strTemp) > -1) 
  12.      { 
  13.           ichar++; 
  14.      } 
  15.      else 
  16.      { 
  17.           ichi++; 
  18.      } 
  19. this.textBox2.Text = "数字:" + inum.ToString(); 
  20. this.textBox3.Text = "字母:" + ichar.ToString(); 
  21. this.textBox4.Text = "汉字:" + ichi.ToString(); 
设为首页 | 加入收藏 | 网学首页 | 原创论文 | 计算机原创
版权所有 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2020 myeducs.Cn www.myeducs.Cn All Rights Reserved 湘ICP备09003080号 常年法律顾问:王律师