How to convert a list of characters into a string in C#?


Firstly, set the characters.

char[] arr = new char[5];
arr[0] = 'Y';
arr[1] = 'E';
arr[2] = 'S';

Now, convert them into string.

string res = new string(arr);

The following is the complete code to convert a list of characters into a string −

Example

 Live Demo

using System;

class Program {
   static void Main() {
      char[] arr = new char[5];
      arr[0] = 'Y';
      arr[1] = 'E';
      arr[2] = 'S';

      // converting to string
      string res = new string(arr);

      Console.WriteLine(res);
   }
}

Output

YES

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 22-Jun-2020

158 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements