Ergebnis 1 bis 7 von 7
-
Mich gibt's schon länger
- 11.09.2012, 17:46
- #1
Hallo Community, ich bitte euch noch ein mal um Hilfe. Ich versuche mich an C# for Windows Phone und versuche gerade einen Text zu splitten. Also z.B. die Eingabe eines Users: "Hallo + Wie + Geht + Es + Dir" in "Hallo wie geht es dir".
vielleicht hilft euch das weiter bei meinem Problem. Wie kann ich jetzt nur die Worte wieder ausgeben? Eventuell auch Zahlen davon trennen? Und wenn wir so weit kommen, die Wörter in Strings Speichern und Die Zahlen weiter nutzen in Ints? Wäre super wenn ihr mir dabei behilflich sein könntCode:[FONT=Consolas][FONT=Consolas][FONT=Consolas]private[/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]void[/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas] Button_Click_1([/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]object[/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas] sender, [/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]RoutedEventArgs[/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas] e)[/FONT][/FONT] [FONT=Consolas][FONT=Consolas] { [/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]string[/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas] userEingabe;[/FONT][/FONT] [FONT=Consolas][FONT=Consolas] userEingabe = myTextBox1.Text; [/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]char[/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas][] delimiterChars = { [/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]' '[/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas],[/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]'+'[/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas]};[/FONT][/FONT] [FONT=Consolas][FONT=Consolas] [/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]string[/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas] text = userEingabe;[/FONT][/FONT] [FONT=Consolas][FONT=Consolas] [/FONT][/FONT][FONT=Consolas][FONT=Consolas] myTextBlock1.Text = text; [/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]//ausgabe des Originaltextes[/FONT][/FONT][/FONT] [FONT=Consolas][FONT=Consolas][FONT=Consolas] [/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas] [/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]string[/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas][] words = text.Split(delimiterChars);[/FONT][/FONT] [FONT=Consolas][FONT=Consolas] [/FONT][/FONT][FONT=Consolas][FONT=Consolas] myTextBlock2.Text = words.Length.ToString(); [/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]//ausgabe der anzahl der Wörter[/FONT][/FONT][/FONT] [FONT=Consolas][FONT=Consolas][FONT=Consolas] [/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas] [/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]foreach[/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas] ([/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]string[/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas] s [/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]in[/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas] words)[/FONT][/FONT] [FONT=Consolas][FONT=Consolas] { [/FONT][/FONT][FONT=Consolas][FONT=Consolas] myTextBlock3.Text = s; [/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]// alle einzelnen wörter??????[/FONT][/FONT][/FONT] [FONT=Consolas][FONT=Consolas][FONT=Consolas] [/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas] } [/FONT][/FONT]
ich hoffe ihr versteht mein Problem. danke im Vorraus Agredo
-
- 11.09.2012, 18:07
- #2
du hast die Wörte in einen array gespeichert. also musst du diesen wieder zusammenfügen.
Code:string strFiller; foreach (string s in words) { strFiller += s; // fügt jedes mal s zu strFiller hinzu. strFiller = strFiller+s; // geht genau so, ist nur nicht so hübsch ;) } myTextBlock3.Text = strFiller; //und nun ausgeben
-
Mich gibt's schon länger
- 11.09.2012, 18:18
- #3
danke dür die schnelle Antwort aber er gibt mir dann als Fehlermeldung: Verwendung der nicht zugewiesenen lokalen Variablen "strFiller" also in der Zeile: strFiller += s;
-
Gehöre zum Inventar
- 11.09.2012, 18:36
- #4
-
Mich gibt's schon länger
- 11.09.2012, 18:48
- #5
jaa, danke
jetzt klappt das ja schon mal FAST
jetzt gibt er mir, wenn ich zum Beispiel "Hallo+wie+geht+es+dir" schreibe. Hallowiegehtesdir.
wenn ich es richtig verstanden habe, habe ich doch die einzelnen Wörter in Arrays gespeichert, oder? also kann ich diese aus word [0] als einzelnes wort ausgben? Geht dieses dann auch aus einem mix aus Zahlen und Wörtern? zB. hallo3+wie2+geht1+es4+dir5 in hallo wie geht es dir und 3 2 1 4 5 ?
-
- 11.09.2012, 21:10
- #6
ja kannst du, genau.
-
Gehöre zum Inventar
- 12.09.2012, 12:15
- #7
Na ja, bei nem int[] Array muss er dann halt erst noch ToString() aufrufen, sonst wird das Plus nämlich die Zahlen addieren statt sie hintereinanderzuhängen. Hast du jedoch die Zahlen in einem String[] Array geht es so wie hier beschrieben.
arr[0].ToString() wandelt dir wenn arr ein Int-Array ist den Wert an der Stelle 0 zu einem String um
Int32.Parse(arr[0]) wandelt dir wenn arr ein String-Array ist den String an der Stelle 0 zu einem Int um (vorrausgesetzt da steht eine Zahl drinnen in einem Format, dass geparst werden kann - wenn der String jetzt aber "Hallo" ist dann gibts ne Exception).
Ähnliche Themen
-
Hilfe/Fehler beim laden von Android
Von Mille1986 im Forum HTC HD2 AndroidAntworten: 12Letzter Beitrag: 23.10.2010, 14:10 -
Hilfe beim Installieren von Apps
Von Unregistriert im Forum Android AllgemeinAntworten: 4Letzter Beitrag: 22.04.2010, 09:38 -
HTC TD 2: Kontakte (windows original): Notizen: Strings selektieren geht nicht
Von pwallenb im Forum HTC Touch Diamond 2Antworten: 1Letzter Beitrag: 05.10.2009, 15:08 -
Brauche Hilfe beim installieren von Spiel.
Von Piega85 im Forum Touch HD FunAntworten: 12Letzter Beitrag: 08.05.2009, 20:49 -
Brauche Hilfe beim Installieren von G-Flow
Von Rhaki im Forum HTC Touch DiamondAntworten: 3Letzter Beitrag: 27.10.2008, 20:37

Danke:














Mobile Gaming: 2030 spielen auf...