static?int?Count(string?WithinString,?string?search) { if?(string.IsNullOrEmpty(search)) throw?new?ArgumentNullException("search"); int?counter?=?0; int?index?=?WithinString.IndexOf(search,?0); while?(index?>=?0?&&?index?<?WithinString.Length) { counter++; index?=?WithinString.IndexOf(search,?index?+?search.Length); } return?counter; }
然後用Count(要查找的字條串," ") 就可以取空格數量了
上一篇:醋中的黑色顆粒沈澱是什麽?下一篇:LED08C快速門顯示er 10