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.

39,936 questions

51,873 answers

573 users

How to concatenate (combine) characters into a string with C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(CharCombine('a', 'b', 'c', 'd'));
            Console.WriteLine(CharCombine('x', 'y', 'z'));
            Console.WriteLine(CharCombine('q', 'w'));
        }
        public static string CharCombine(char ch0, char ch1, char ch2, char ch3)
        {
            char[] arr = new char[4];
            arr[0] = ch0;
            arr[1] = ch1;
            arr[2] = ch2;
            arr[3] = ch3;

            return new string(arr);
        }
        public static string CharCombine(char ch0, char ch1, char ch2)
        {
            char[] arr = new char[3];
            arr[0] = ch0;
            arr[1] = ch1;
            arr[2] = ch2;

            return new string(arr);
        }
        public static string CharCombine(char ch0, char ch1)
        {
            char[] arr = new char[3];
            arr[0] = ch0;
            arr[1] = ch1;

            return new string(arr);
        }
    }
}


/*
run:
 
abcd
xyz
qw

*/

 



answered Mar 13, 2017 by avibootz

Related questions

3 answers 76 views
2 answers 91 views
91 views asked Jul 13, 2023 by avibootz
2 answers 134 views
2 answers 197 views
2 answers 212 views
1 answer 181 views
...