I was working on a piece of code where the name of the person was stored like
The requirement was to swap these two words and instead make it look like
Here’s how to swap two words using LINQ in .NET 4.0
public static void Main()
string name = "Suprotim, Agarwal";
name = string.Join(", ", name.Split(',').Reverse()).Trim();
Dim name As String = "Suprotim, Agarwal"
name = String.Join(", ", name.Split(","c).Reverse()).Trim()