“FirstName, LastName”
The requirement was to swap these two words and instead make it look like
“LastName, FirstName”
Here’s how to swap two words using LINQ in .NET 4.0
C#
public static void Main() { string name = "Suprotim, Agarwal"; name = string.Join(", ", name.Split(',').Reverse()).Trim(); Console.WriteLine(name); Console.ReadLine(); }VB.NET
Sub Main() Dim name As String = "Suprotim, Agarwal" name = String.Join(", ", name.Split(","c).Reverse()).Trim() Console.WriteLine(name) Console.ReadLine() End SubOUTPUT
No comments:
Post a Comment