Determining the Number of Indices of a Substring within a StringsubstringindicesDetermining the Number of Indices of a Substring within a StringC# .Net Fun - http://www.dotnetfun.com - Michael G.strSourceStringSystem.StringThe source string to search for the number of indices of a substring."as as as as as"strSearchStringSystem.StringThe search string to search for in the source string."as"
-1)
{
intNumIndices++;
intStartIndex = strSourceString.IndexOf(strSearchString, intStartIndex) + strSearchString.Length;
}
// intNumIndices = 5
]]>