Autor Beitrag
Matti
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Mo 16.10.06 16:36 
Hi,

ich will in einem String die Anzahl der Semikolons zählen und in net Int16 Variable schreiben ...

Ich habe allerdings keine Ahnung wie ich die durchführen kann ... Bitte helft mir !!

mfg, Matti
gozza01
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mo 16.10.06 17:39 
Titel: So in etwa
ausblenden C#-Quelltext
1:
2:
3:
string strQuelle = "1;2;3;4;5";
string[] split = strQuelle.Split(';');
Int16 iAnzahl = (Int16)(split.Length - 1);


Moderiert von user profile iconChristian S.: C#-Tags hinzugefügt


Zuletzt bearbeitet von gozza01 am Mo 16.10.06 18:01, insgesamt 1-mal bearbeitet
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 16.10.06 17:54 
Wieso ein Array anlegen, um zu erfahren, wieviel Semikolon drin vorkommen? :gruebel:

Eher so:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
string strQuelle = "1;2;3;4;5";
int count = 0;
int position = -1;
do {
  position = strQuelle.IndexOf(";", position+1);
  if (position > -1)
    count++;
while (position <> -1)


Ist ungetestet, sollte aber so laufen.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".