Click here to Skip to main content
15,919,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have an int variable aaa with the value 100. 100 corresponds to "d" in ASCII.
I want to assign this to a string variable abc so that abc has the value "d" and not 100.

How can I do this?

when I give the below code, I get the error error CS0029: Cannot implicitly convert type 'int' to 'string'
C#
int aaa = 100;
string abc = aaa;


but when I do
C#
abc = aaa.ToString()
, I see that abc becomes "100". But I want abc to become "d".

How can I do this?
Posted
Updated 12-Sep-12 0:51am
v2

Hello,

Please use below code snippet
C#
int aaa = 100;
char converted = Convert.ToChar(aaa);


Please refer below link for more detail :
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/c4a3ea1d-72f2-4482-954e-87b3d154c4fb[^]


Please let us know your feedback if any.
 
Share this answer
 
v3
Use this code below:
C#
int aaa = 100;
char a = char(aaa); // Now a will contain d.
 
Share this answer
 
int
C#
aaa = 100;
if (aaa = 100)
{
string abc = d;

}
 
Share this answer
 
First convert it to ASCII code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900