去掉每行的行号及将中文标点转化成英文

/// <summary> /// 字符串的截断 /// </summary> /// <param name="charDel">从字符之前被截断</param> private string[] DelBeforeChar(string[] txt, char charDel) { //string[] txt = richTextBox1.Lines; string[] newtxt = new string[txt.Length]; for (int i = 0; i < txt.Length; i++) { newtxt[i] = txt[i].Substring(txt[i].IndexOf(charDel) + 1); } return newtxt; } /// <summary>半角转成全角 /// 半角空格32,全角空格12288 /// 其他字符半角33~126,其他字符全角65281~65374,相差65248 /// </summary> /// <param name="input"></param> /// <returns></returns> public string DBCToSBC(string input) { char[] cc = input.ToCharArray(); for (int i = 0; i < cc.Length; i++) { if (cc[i] == 32) { // 表示空格 cc[i] = (char)12288; continue; } if (cc[i] < 127 && cc[i] > 32) { cc[i] = (char)(cc[i] + 65248); } } return new string(cc); } /// <summary>全角转半角 /// 半角空格32,全角空格12288 /// 其他字符半角33~126,其他字符全角65281~65374,相差65248 /// </summary> /// <param name="input"></param> /// <returns></returns> public string SBCToDBC(string input) { char[] cc = input.ToCharArray(); for (int i = 0; i < cc.Length; i++) { if (cc[i] == 12288) { // 表示空格 cc[i] = (char)32; continue; } if (cc[i] > 65280 && cc[i] < 65375) { cc[i] = (char)(cc[i] - 65248); } } return new string(cc); } private string[] ChineseToEnglish(string[] txt) { string[] ChineseInterpunction = new string[] { "“", "”", "‘", "’", "。", ",", ";", ":", "?", "!", "……", "—", "~", "(", ")", "《", "》" }; string[] EnglishInterpunction = new string[] { "/"", "/"", "'", "'", ".", ",", ";", ":", "?", "!", "…", "-", "~", "(", ")", "<", ">" }; for (int i = 0; i < txt.Length; i++) { for (int j = 0; j < ChineseInterpunction.Length; j++) { txt[i] = txt[i].Replace(ChineseInterpunction[j], EnglishInterpunction[j]); } } return txt; } /// <summary> /// 去掉的按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { string[] txt = richTextBox1.Lines; string[] newtxt = new string[richTextBox1.Lines.Length]; newtxt = txt; if (radioButton1.Checked == true) { newtxt = DelBeforeChar(newtxt, Convert.ToChar(radioButton1. Text.ToString())); } if (radioButton2.Checked == true) { newtxt = DelBeforeChar(newtxt, '.'); } if (checkBox1.Checked == true) { newtxt = ChineseToEnglish(newtxt); } richTextBox2.Lines = newtxt; }

你可能感兴趣的:(String,object,input,button,RadioButton)