skipter icon

C# Methods - Find the Nth Digit

skipter | PRO | 06/20/17 10:56:08 AM UTC | 0 ⭐ | 421 👁️ | Never ⏰ | []
C# |

680 B

|

None

|

0 👍

/

0 👎

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Arrays_and_Methods___Exercise
{
    class Program
    {
        static void Main(string[] args)
        {
            string number = Console.ReadLine();
            int indexN = int.Parse(Console.ReadLine());
            Console.WriteLine(FindTheNthDigit(number, indexN));
        }
        public static char FindTheNthDigit(string numberForResearch, int index)
        {
            int returnIndex = numberForResearch.Length - index;
            char result = numberForResearch[returnIndex];
            return (char) result;
        }
    }
}

Comments