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 238 views
238 views asked Nov 28, 2019 by avibootz
3 answers 388 views
388 views asked Mar 3, 2017 by avibootz
1 answer 312 views
2 answers 377 views
1 answer 316 views
316 views asked Nov 30, 2019 by avibootz
1 answer 287 views
287 views asked Nov 30, 2019 by avibootz
3 answers 421 views
...