有沒有辦法在C#中執行以下操作,但我正在查找和.indexOf沒有粘貼給我。它是否存在,或者我應該使用什麼其他方法?如何在C#中搜索匹配的字符串數組,如我的代碼
string t = "joke";
string sentence = "there is no joke here";
string[] array = sentence.Split(" ".ToCharArray());
//here is the kicker
int count = array.indexOf(t);
return count;
這應該返回3?
你想要它3,因爲笑話是第4個字? – Maess 2012-07-12 19:36:43
是的,這是正確的。 – Fallenreaper 2012-07-12 19:41:12