一共仨控件: mNum mTxt1 mTxt2 这个 button就不算在里了。。
private void button1_Click(object sender, EventArgs e)
{
string m = this.mTxt1.Text.ToString();
int n = Convert.ToInt32(this.mNum.Text.ToString());
for (int i = 0; i <= n; i++)
{
m = m.Replace("第" + i + "位", "第" + retNum(i.ToString()) + "位");
}
this.mTxt2.Text = m;
}
public string retNum(string n)
{
if (n.Length == 2)
{
string n1 = n.Substring(0, 1);
string n2 = n.Substring(1, 1);
if (n1 == "1")
{
n1 = "";
}
if (n2 == "0")
{
n2 = "";
}
return retOneNum(n1) + "十" + retOneNum(n2);
}
else
{
return retOneNum(n);
}
}
public string retOneNum(string n)
{
string k = n;
k = k.Replace("1", "一");
k = k.Replace("2", "二");
k = k.Replace("3", "三");
k = k.Replace("4", "四");
k = k.Replace("5", "五");
k = k.Replace("6", "六");
k = k.Replace("7", "七");
k = k.Replace("8", "八");
k = k.Replace("9", "九");
k = k.Replace("0", "零");
return k;
}