Select last element after Split in C#
To select last element after a split in C# we can useLast()
method.Example of selecting last element after split in C#
using System;
using System.Linq;
public class Program
{
public static void Main()
{
string str = "hi,1,hello,2,user,3";
string stringCutted = str.Split(',').Last();
Console.WriteLine(stringCutted);
}
}
Output
3