Answers for "c# split quotation"

C#
0

c# split quotation

string myString = "WordOne "Word Two"";
var result = myString.Split('"')
                     .Select((element, index) => index % 2 == 0  // If even index
                                           ? element.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)  // Split the item
                                           : new string[] { element })  // Keep the entire item
                     .SelectMany(element => element).ToList();

Console.WriteLine(result[0]);
Console.WriteLine(result[1]);
Console.ReadKey();
Posted by: Guest on December-24-2021

C# Answers by Framework

Browse Popular Code Answers by Language