Je ne sais justement pas comment m'y prendre
Je dois entrer un chiffre dans un textBox
exemple :49565
Quand je clique sur Décompresser
Il m'affiche :
5
65
565
9565
49565
dans un autre textBox
Merci de bien vouloir m'aider
Je ne sais justement pas comment m'y prendre
Je dois entrer un chiffre dans un textBox
exemple :49565
Quand je clique sur Décompresser
Il m'affiche :
5
65
565
9565
49565
dans un autre textBox
Merci de bien vouloir m'aider
Salut,
ta textbox contient des strings donc je pense qu'il faut faire comme ca:
Le seul problème s'est qu'il part de gauche à droite et non de droite à gauche
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 string val = ""; foreach (char c in textbox1.Text) { val += c; textbox2.Text = val; }![]()
Du coup, je propose d'utiliser un for à la place du foreach, en commencant à l'indice de la taille de la chaine![]()
salut
ou pour faire "simple" :
The Monz, Toulouse
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 private string GetDecomposition(string p) { StringBuilder data = new StringBuilder(); for (int i = p.Length-1; i >=0 ; i--) { data.AppendLine(p.Substring(i)); } return data.ToString(); }
Je commence en C et j'ai cela... je place ça à quel endroit. Merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void textBox2_TextChanged(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { } private void textBox2_TextChanged_1(object sender, EventArgs e) { } } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { textBox2.Text = GetDecomposition(textBox1.Text); } private string GetDecomposition(string p) { StringBuilder data = new StringBuilder(); for (int i = p.Length-1; i >=0 ; i--) { data.AppendLine(p.Substring(i)); } return data.ToString(); } } }![]()
Partager