You could check if the input was "N" before you attempt to parse it as an int:
int pg = 0;
int x = 1;
int index = 0;
Console.WriteLine("Enter numbers, press n to stop:");
while (true) {
string input = Console.ReadLine();
if (input.Equals("N", StringComparison.OrdinalIgnoreCase)) {
break;
}
if (!int.TryParse(input, out var n)) {
continue; // Wasn't parseable as int, so loop back round.
}
if (n > pg) {
pg = n;
index = x;
}
x++;
}
Console.WriteLine("Largest number is: {0} ", pg);
Console.WriteLine("Position in line : {0}", index);
This will skip over input that wasn't parseable as int too.