Count occurrences of a substring: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|C sharp}}: Regularize header markup to recommended on category page) |
|||
Line 985: | Line 985: | ||
var count = 0 |
var count = 0 |
||
while true { |
while true { |
||
idx = str. |
idx = str.IndexOf(val, idx) |
||
if idx == -1 { |
if idx == -1 { |
||
break |
break |
||
} |
} |
||
idx += val. |
idx += val.Length() |
||
count += 1 |
count += 1 |
||
} |
} |