14

How do I combine two char's into a single string?

It seems as I cannot for the life of me find out how to do it whatsoever.

Ola Ström
  • 4,136
  • 5
  • 22
  • 41
Enenra Kage
  • 163
  • 1
  • 1
  • 6
  • 2
    How about this method? `'A'.ToString() + 'B'.ToString()` Simply use `ToString` method and then add the strings. – jitendragarg Jul 02 '17 at 09:50
  • 3
    While jitendragarg's method works, it creates more garbage than is necessary. Two garbage strings for a single resulting string. Fruchtzwerg's method creates a single garbage object for the resulting string. – Eric Vasilik Feb 20 '20 at 02:48

1 Answers1

25
char[] chars = {'a', 'b'};
string s = new string(chars);
Fruchtzwerg
  • 10,999
  • 12
  • 40
  • 49