Engines/FlatRedBallXNA/FlatRedBall/Utilities/StringFunctions.cs
/// <summary>
/// Returns the number of times that the argument whatToFind is found in the calling string.
/// </summary>
/// <param name="instanceToSearchIn">The string to search within.</param>
/// <param name="whatToFind">The string to search for.</param>
/// <returns>The number of instances found</returns>
Returns the number of times that the argument whatToFind is found in the calling string.
Returns the number of times that the argument whatToFind is found in the calling string .
public static int CountOf(this string instanceToSearchIn, string whatToFind)
        {
            int count = 0;
            int index = 0;
            while (true)
            {
                int foundIndex = instanceToSearchIn.IndexOf(whatToFind, index);
                if (foundIndex != -1)
                {
                    count++;
                    index = foundIndex + 1;
                }
                else
                {
                    break;
                }
            }
            return count;
        }
public static int CountOf ( this string instanceToSearchIn , string whatToFind ) { int count = 0 ; int index = 0 ; while ( true ) { int foundIndex = instanceToSearchIn . IndexOf ( whatToFind , index ) ; if ( foundIndex != - 1 ) { count ++ ; index = foundIndex + 1 ; } else { break ; } } return count ; }
Returns the number of times that the argument whatToFind is found in the calling string.
Returns the number of times that the argument whatToFind is found in the calling string .
The number of instances found
The number of instances found
string
this
whatToFind
string
The string to search for.
The string to search for .
instanceToSearchIn
The string to search within.
The string to search within .