<pre name="code" class="csharp">private void button1_Click(object sender, EventArgs e)
{
int x = 0;
string add="";
if (textBox1.Text == "")
MessageBox.Show("不允许输入空值");
else
{
foreach (char a in textBox1.Text)
{
x+= a;
add += x.ToString()+" ";
x = 0;
}
}
textBox2.Text = add;
}
简单的转换 转换后的数每一个都加空格来区分
private void button1_Click(object sender, EventArgs e)
{
string asc = textBox1.Text;
string[] word = asc.Split(new string[] { " ", " " }, StringSplitOptions.RemoveEmptyEntries);
;//split 截取每个汉子代表的ascII 并去掉空格
ArrayList List = new ArrayList();//动态长度的数组
int[] num =new int[] { };
string tx="";
for (int i = 0; i < word.Length; i++)
{
List.Add(Convert.ToInt32(word[i]));//填充动态数组
}
num = (int[])List.ToArray(typeof(int));//转换为所需类型的数组
for (int j = 0; j < num.Length; j++)
{
tx += ((char)num[j]).ToString();//ASCII转换为文本
}
textBox2.Text = tx;
}