使用winform
nuget:
页面:
俩TextBox控件
后台:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using TinyPinyin;
namespace two_Winform
{
public partial class 将汉字转换成拼音 : Form
{
public 将汉字转换成拼音()
{
InitializeComponent();
}
private void TextBox1_TextChanged(object sender, EventArgs e)
{
string chineseText = textBox1.Text;
string pinyin = string.Empty;
if (!string.IsNullOrEmpty(chineseText))
{
pinyin = PinyinHelper.GetPinyin(chineseText);
}
textBox2.Text = pinyin;
}
}
}