Advertisement
skipter

C# Methods - Find the Nth Digit

Jun 20th, 2017
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Arrays_and_Methods___Exercise
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string number = Console.ReadLine();
  14.             int indexN = int.Parse(Console.ReadLine());
  15.             Console.WriteLine(FindTheNthDigit(number, indexN));
  16.         }
  17.         public static char FindTheNthDigit(string numberForResearch, int index)
  18.         {
  19.             int returnIndex = numberForResearch.Length - index;
  20.             char result = numberForResearch[returnIndex];
  21.             return (char) result;
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement