ascii to character - character to ascii

Character to ASCII :

------- Single Character Convertion to ASCII --------
char c = 'A';
int i = (int) c;
Console.WriteLine(i);
------------------------------------------------------

--String Conversion to ASCII using String Variable--
String str = "aspdotnet";
foreach(char c in str)
{
Console.WriteLine((int) c);
}
------------------------------------------------------

--String Conversion to ASCII using StringBuilder----
string str = "aspdotnet";
StringBuilder res = new StringBuilder();
foreach(char c in str )
{
if (Char.IsLetter(c))
res.Add(c);
}
Console.WriteLine(res);
-----------------------------------------------------

--String Conversion to ASCII using for loop ---------
string str= "aspdotnet";
for (int i = 0; i <> " + Char.ConvertToUtf32(str, i));
}
----------------------------------------------------

ASCII to Character :

--------Convertion of ASCII to Char---------------
int i = 65;
char c = (char) i;
Console.WriteLine(c);
---------------------------------------------------


No comments: