do
                {
                  Console.Write("     <jaar 1582 - 2500>...");
                } while(!int.TryParse(Console.ReadLine(), out jaar) && jaar < 1582);

Why doesn't this work in C#?
you can't test a integeren in a do while when there's a tryparse apperently
whats the best way of doing this?

Thank you for your time.

Recommended Answers

All 2 Replies

Why doesn't this work in C#?

Because you should be using || in your loop rather than &&. With &&, jaar will only be compared to 1582 if TryParse fails, which is somewhat nonsensical.

Thank you for clearing this up.
And I now see the flaws in my logic. I should've known this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.