/// <summary>
/// Returns the contents of a string starting with the location of the searchFor
/// </summary>
/// <param name="s">The string to search.</param>
/// <param name="searchFor">The string to search for.</param>
/// <returns></returns>
public static string TakeFrom(this string s, string searchFor)
	if (s.Contains(searchFor))
		int length = Math.Max(s.Length, 0);

		int index = s.IndexOf(searchFor);

		return s.Substring(index, length - index);

	return s;
string s = "abcde";

Console.WriteLine (s.TakeFrom("d"));   // "de"


Returns the remaining characters in a target string, starting from a search string. If the search string is not found in the target, it returns the full target string.


Double click on the code to select all.