How to get the second digit of a number in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        const int num = 784190;
        
        string secondDigit_string = num.ToString();
        
        int secondDigit_number = secondDigit_string[1] - 48;
        
        Console.WriteLine(secondDigit_number);
    }
}




/*
run:

8

*/

 



answered Jun 17, 2022 by avibootz
edited Jun 17, 2022 by avibootz

Related questions

1 answer 109 views
1 answer 176 views
1 answer 123 views
1 answer 134 views
1 answer 120 views
1 answer 113 views
...