Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 631301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:56:59+00:00 2026-05-13T19:56:59+00:00

I have a litte problem on Console.WriteLine() . I have my while(true) loop that

  • 0

I have a litte problem on Console.WriteLine(). I have my while(true) loop that would check the data if exist and it would allow checking the data 3 times. And inside my loop I have this message:

Console.WriteLine(string.format(“Checking data {0}”,ctr));

Here’s my sample code below:

int ctr = 0;

while(true)
{
  ctr += 1;

  Console.WriteLine(string.format("Checking data {0}...",ctr))  

  if(File.Exist(fileName)) 
     break;

  if(ctr > 3)
     break;

}

Let’s assume that data was not found.

My current output show like this:

Checking data 1...
Checking data 2...
Checking data 3...

But the correct output that I should want to achieve should looks like this:

Checking data 1...2...3...

I would show only in one line.

Edit:

I forgot: In addition to my problem I want to append “Not Found” and “Found”.

Here’s the sample Output:

  1. if data found on the First loop output looks like this.

    Checking data 1… Found!

  2. if data found on the Second loop output looks like this.

    Checking data 1…2…Found!

  3. if data found on the Third loop output looks like this.

    Checking data 1…2…3…Found!

AND If data not found

  1. Checking data 1…2…3… Not Found!
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:56:59+00:00Added an answer on May 13, 2026 at 7:56 pm

    Use Console.Write instead if you don’t want the line break. You also need to move the text out of the loop to avoid repeating it. Something like

    Console.WriteLine("Checking data");
    int ctr = 0;
    bool found = false; 
    
    while (ctr++ < 3 && !found) {
       Console.Write(" {0}...", ctr);
       if (File.Exists(fileName)) found = true;
    }
    Console.WriteLine(found ? "Found" : "Not found");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem with a simple console application in which i would
I have a litte problem here. I want to join twice from the same
I have a little Problem with the app that I'm developing. In the App
So I have a little Linux problem, geez that will teach me to spend
Here's a little problem I've been thinking about for a while now that I
I have a little console application that among other things checks the status of
I have a little problem with my R console recently. When I start R
We have an application that has one or more text console windows that all
i have a problem with that exception, actually, when i click on the calloutAccessoryControlTapped
I'm writing a console program that uses DirectSound API to render some audio data.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.