Check if a word is before another
You're naming your parameters incorrectly. The naming guidelines for parameters specify camel casing.

Your method declaration should look like this:

public static bool IsWordABeforeWordB(string text, string wordA, string wordB)




Your current implementation also has a bug. You are assuming that the source text contains wordB - if it doesn't you'll get an ArgumentOutOfRangeException on the substring.



I'd suggest that performance probably doesn't matter here so you may as well just do it the long way:

public static bool IsWordABeforeWordB(string text, string wordA, string wordB)
{
    // Omitted checking text, wordA and wordB for null.
    var indexOfFirstWordA = text.IndexOf(wordA, StringComparison.OrdinalIgnoreCase);
    if (indexOfFirstWordA == -1)
    {
         // throw exception or return false.
    }
    var indexOfLastWordB = text.LastIndexOf(wordB, StringComparison.OrdinalIgnoreCase);
    if (indexOfLastWordB == -1)
    {
        // throw exception or return false.
    }

    // edited based on holroy's comment.
    // Otherwise we'd be wrong if wordB was a substring of wordA
    // e.g. wordA: hello, wordB: lo 
    return indexOfFirstWordA + wordA.Length &lt; indexOfLastWordB;

}


I've assumed that IsWordABeforeWordB("Sample text is sample", "text", "sample") should return true as "text" does appear before one of the "sample"s. If that's not the behaviour you were going for you can change the LastIndexOf to a simple IndexOf



The definition of a "word" is a bit loose here. You could do a Regular Expression match to get the indexes which would allow you to use the "\b" word anchor. I've just assumed (as your OP) that it's simply a sequence of characters.