1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| private string _texte,_texte2 = string.Empty;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var dico = new Dictionary<string, string>
{
{"<<prenom>>", "un"},
{"<<nom>>", "deux"}
};
foreach (var kvp in dico)
{
_texte2 = _texte.Replace(kvp.Key, kvp.Value);
}
textBox2.Text = _texte2;
}
private string RemplirTextbox1()
{
return textBox1.Text = @"salut <<prenom>>, <<nom>> et toi <<prenom>>";
}
private void Form1_Load(object sender, EventArgs e)
{
_texte = RemplirTextbox1();
} |