【发布时间】:2019-02-01 12:46:05
【问题描述】:
我试图找出“Serotonin”一词在收集的网络数据中出现了多少次,但找不到找到次数的方法。
IEnumerator OnMouseDown()
{
string GatheredData;
StringToFind = "Serotonin"
string url = "https://en.wikipedia.org/wiki/Dopamine";
WWW www = new WWW(url);
yield return www;
GatheredData = www.text;
//Attempted methods below
M1_count = GatheredData.Contains(StringToFind);
M1_count = GatheredData.Count(StringToFind);
M1_count = GatheredData.IndexOf(StringToFind);
}
当我告诉它索引中的数字和方法 2 可以使用但仅适用于字符而不是字符串时,我可以轻松地使用方法 1 和 3 中的数据
我已经在网上和这里查过,但没有找到 StringToFind 的计数
【问题讨论】:
-
GatheredData.IndexOf(string/char StringToFind,int starindex,int count);
-
哦,是的,位移方法……如果没有内置方法,那会起作用
-
首选索引,我怎么知道除了 indexof 之外还有多少直到 null?或者这就是方法?
标签: c# unity3d count substring indexof