C#如何去掉字符串中所有空格

由于空格的ASCII码值是32,因此,在去掉字符串中所有的空格时,只需循环访问字符串中的所有字符,并判断它们的ASCII码值是不是32即可。去掉字符串中所有空格的关键代码如下:   CharEnumeratorCEnumerator=textBox1.Text.GetEnumerator();   while(CEnumerator.MoveNext())   {   byte[]array=newbyte[1];   array=System.Text.Encoding.ASCII.GetBytes(CEnumerator.Current.ToString());   in...
默认分类 | 2010-12-12 09:44 | 阅读 963 次 | 评论 0 条

c#中英文混合字符串截取指定长度

 //字符是否为汉字   public bool IsChinese(char c)   {   return (int)c >= 0x4E00 &amp;&amp; (int)c <= 0x9FA5;   }   //获得字节长度   private int getLengthb(string str)   {   return System.Text.Encoding.Default.GetByteCount(str);   }   //c#的中英文混合字符串截取指定长度,startidx从0开始 by   public string getStrLenB(st...
默认分类 | 2010-12-12 09:43 | 阅读 920 次 | 评论 0 条
浏览2893次
文章分类
最新评论