Answers for "remove last instance of string c#"

C#
0

remove last instance of string c#

public static string ReplaceLastOccurrence(string Source, string Find, string Replace)
{
        int place = Source.LastIndexOf(Find);

        if(place == -1)
           return Source;

        string result = Source.Remove(place, Find.Length).Insert(place, Replace);
        return result;
}
Posted by: Guest on December-14-2020

Code answers related to "remove last instance of string c#"

C# Answers by Framework

Browse Popular Code Answers by Language