日期:2014-05-17  浏览次数:20954 次

C# 过滤字符串中的汉字,效率高点的
例如: string content = "13440900984\r\n13440900984\r\n你好\r\n13440900984\r\n你好\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984你好\r\n鸟\r\n13440900984\r\n13440900984\r\n";


有时候字符串可能会比较长,所以求效率比较好的。。
要求过滤之后:
string content = "13440900984\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984\r\n13440900984\r\n";
------最佳解决方案--------------------
   if(radioButton1.Checked){ control = form2.zhucex;}
                else if(radioButton2.Checked){ control =form3.zhuces;}
                else if(radioButton3.Checked){ control = warring;}
                else if(radioButton4.Checked){ control =suggest;}
                else if(radioButton5.Checked){ control =form4.mumawe;}
                else if(radioButton6.Checked){ control =drop;}
                if (control =="000000")
                {
                    MessageBox.Show("你没有输入任何控制目标!不发控制信号");
                    richTextBox1.AppendText("你没有输入任何控制目标!不发控制信号");
                }
                else if(control != "000000")
                {
                    try
                    {
                            //记录操作
                    richTextBox1.AppendText (control + "正在试图控制,等待回应......" + "\r");
                        stream = client.GetStream();
                        if(stream.CanWrite )
                        {
                        byte[] by = System.Text.Encoding.ASCII.GetBytes(control.ToCharArray ());
                     &nbs