Change you code to this:
int i = 0;
int n = 4;
while(i<10)
{
i = i + 1;
if(i = n)
Console.WriteLine("You have reached the {0}{1} position of ascending order", n, GetEnding(n));
else
Console.WriteLine(i);
Console.ReadLine();
}
Then add the method:
private string GetEnding(int n)
{
var ones = n % 10;
switch(ones)
case 1:
return "st";
case 2:
return "nd";
case 3:
return "rd";
default:
return "th";
}
That should do what you want, it should also make it that if you change n it continues to work. (i believe).
An alternative to the GetEnding method can be found in this thread:
Is there an easy way in .NET to get “st”, “nd”, “rd” and “th” endings for numbers?[
^]