Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C#

Good morning, I am having trouble on spoting the mistake I did in this code(it is not working), Thannk you

""" C#

using System;

namespace ola { class Program { static void Main() { // prompt the user for minutus bool keepgoing = true;

      while(keepgoing)
    {
    Console.Write("enter how many minutes you exerciced or type quit to quit");
  string datafirst = Console.ReadLine();
    if(datafirst == "quit")
    {
      keepgoing = "false";
    }
        else 
        {

    int numb = int.parse("datafirst");
        }
    }

    Console.WriteLine("You have exerciced " + numb + " minutes");


    // add minutus exercice to the total
    // display total
  }

} }

I think it might be on Console.ReadLine();

because even when I try to run only this particular code it does not work

1 Answer

Steven Parker
Steven Parker
231,122 Points

You didn't mention what the issue was, but I will guess that it does not build because of the spelling of "parse" with a lower-case "p" instead of "Parse" (capital "P").

Also, I'd guess this program is intended to accumulate a total of the inputs instead of just displaying each entry.

In that case you might initialize the total before the loop and add to it instead of just assigning it:

            int numb = 0;  // initialize before loop
            while (keepgoing)
// <-- other code omitted for brevity -->
                    numb += int.Parse("datafirst");  // "addition assignment"

For future questions, please provide a link to the course page you are working with.