How to convert char to ascii value in C#

1 Answer

0 votes
using System;
 
class Program
{
    static void Main() {
        char ch = 'a';
         
        int n1 = ch;
        Console.WriteLine(n1);
         
        int n2 = (int)ch;
        Console.WriteLine(n2);
         
    }
}
 
 
 
/*
run:
 
97
97
 
*/

 



answered Nov 28, 2019 by avibootz

Related questions

1 answer 159 views
159 views asked Nov 28, 2019 by avibootz
3 answers 259 views
259 views asked Mar 3, 2017 by avibootz
1 answer 219 views
2 answers 274 views
1 answer 211 views
211 views asked Nov 30, 2019 by avibootz
1 answer 199 views
199 views asked Nov 30, 2019 by avibootz
3 answers 273 views
...