Answers for "how to delete last element of array in c#"

C#
3

c# remove last value from list

if(rows.Any()) //prevent IndexOutOfRangeException for empty list
{
    rows.RemoveAt(rows.Count - 1);
}
Posted by: Guest on March-03-2020
1

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 "how to delete last element of array in c#"

C# Answers by Framework

Browse Popular Code Answers by Language