Timer in C#

Asked

Viewed 900 times

0

I am programming the screen of a game where will show the player’s score in progressive mode, it shows the score at the end of the match but does not show with the effect of time between numbers. my while is wrong?

int n = 0;
while (n < sPontuação) 
{
    n++;
}
Console.WriteLine("", n);
  • I didn’t know this function so there was no way I could search for it! How can I change the question?

  • Change why?

  • was marked as duplicate question and I received notice to edit it differently. I am new here on the forum..

  • Voce will keep my question as duplicate?

  • 3

    Yes. It’s duplicate. It’s not?

  • Yes, because what you asked for is already solved in the other question.

  • I understood. I think it goes from point of view, because this existing one would not solve my doubt, I am new in c# and for me just the while was enough..

Show 2 more comments

1 answer

3


Your while is correct, but to give this counting effect you missed using the System.Threading method; which is a timer for millisecond execution.

make that change in while:

int n = 0;
while (n < sPontuação) 
{
    n++;
    System.Threading.Thread.Sleep(3000)
}
Console.WriteLine("", n);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.