C# Linq SelectMany Method

Use SelectMany method to collapse elements into a single collection like an error.

An example would be to convert string to character array. The following is our string array.

string[] str = { "Mobile", "Laptop", "Tablet" };

Now, convert to character array.

str.SelectMany(item => item.ToCharArray());


 Live Demo

using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
   public static void Main() {
      string[] str = { "Mobile", "Laptop", "Tablet" };
      var res = str.SelectMany(item => item.ToCharArray());
      Console.WriteLine("String converted to character array: ");
      foreach (char letter in res) {


String converted to character array:
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know