Hi Friends,
How can I convert char to string ?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Shweta LodhaRank #31 · 39.8K reputationPosted Mar 20, 2014, 5:05 PM EDT
string myString = new string(myCharacter ,1);
or
string myString = myCharacter.ToString()
Graeme Pariot148 reputationPosted Mar 20, 2014, 5:06 PM EDT
Shweta LodhaRank #31 · 39.8K reputationPosted Mar 20, 2014, 5:06 PM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 21, 2014, 1:41 AM EDT
string myString = "" + myCharacter;
This works because the concatenation operator '+' is defined not just for two strings but for a string and an object. In the latter case, the object's ToString() method is invoked to concatenate the two strings together. As one of the strings is empty, you're just left with the character.