【发布时间】:2016-07-18 04:20:54
【问题描述】:
我有一个字符串,例如“这是一个示例”。在这句中是另一个词-“小测试”。我想知道这句话中有多少次是“a little test”。有什么办法吗?谢谢
string tmp = "This a little test is a little test an example. a little test";
int sum = ...... (the count of "a little test")
【问题讨论】:
-
@cookiesoft 虽然提到的问题的标题可能暗示其他情况,但实际问题(和接受的答案)是针对字符串中单个字符的出现,这不是 OP 所要求的跨度>
-
请参阅"Should questions include “tags” in their titles?",其中的共识是“不,他们不应该”!
标签: c# string count sum contains