public static string ConvertToEn(string text) { const string s1 = "。;,?!、“”‘’"; const string s2 = @".;,?!""""''"; char[] c = text.ToCharArray(); for (int i = 0; i < c.Length; i++) { int n = s1.IndexOf(c[i]); if (n != -1) c[i] = s2[n]; } return new string(c); }
//将txtname文本框中输入的中文符号转换成英文符号 string strname=ConvertToEn(this.txtName.Text.ToString());