Converting an array of chars to a string. - CSharp Language Basics

CSharp examples for Language Basics:Data Type Cast

Description

Converting an array of chars to a string.

Demo Code

using System;/*from   w  w w  .java  2 s .c  o m*/
using System.Text;                // Need for type UTF8Encoding.
using System.Globalization;       // Need for cultures.
class Program
{
   static void Main(string[] args)
   {
      // Converting an array of chars to a string.
      Console.WriteLine("\nConvert an array of chars to a string.");
      char[] chars = { 'a', 'b', 'c', 'd' };
      string charsAsString = new String(chars);
      Console.WriteLine("Chars a - d as a string: {0}", charsAsString);
   }
}

Result


Related Tutorials