Hi Friends,
How can I convert char to string ?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Shweta LodhaPosted Mar 20, 2014, 9:05 PM
string myString = new string(myCharacter ,1);
or
string myString = myCharacter.ToString()
VulpesPosted Mar 21, 2014, 5:41 AM
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.
Shweta LodhaPosted Mar 20, 2014, 9:06 PM
Graeme PariotPosted Mar 20, 2014, 9:06 PM