Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

40,026 questions

51,982 answers

573 users

How to convert char array to string in C#

2 Answers

0 votes
using System;
  
class Program
{
    static void Main()
    {
        char[] chars = {'c', ' ', 's', 'h', 'a', 'r', 'p'};
          
        string str = new string(chars);
  
        Console.Write(str); 
    }
}
  
  
/*
run: 
  
c sharp
  
*/

 



answered Jan 10, 2017 by avibootz
edited Aug 8, 2023 by avibootz
0 votes
using System;

class Program
{
    static void Main() {
        char[] arr = new char[13];
 
        arr[0] = 'c';
        arr[1] = '#';
        arr[2] = ' ';
        arr[3] = 'c';
        arr[4] = ' ';
        arr[5] = 'c';
        arr[6] = '+';
        arr[7] = '+';
        arr[8] = ' ';
        arr[9] = 'j';
        arr[10] = 'a';
        arr[11] = 'v';
        arr[12] = 'a';
 
        string str = new string(arr);
        
        Console.WriteLine(str);
    }
}



/*
run:
 
c# c c++ java
 
*/

 



answered Feb 11, 2017 by avibootz
edited Aug 8, 2023 by avibootz

Related questions

2 answers 278 views
278 views asked Jan 9, 2017 by avibootz
1 answer 91 views
1 answer 109 views
1 answer 139 views
139 views asked Jan 21, 2021 by avibootz
1 answer 144 views
1 answer 120 views
1 answer 190 views
190 views asked Jun 3, 2014 by avibootz
...