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 trialHoward Haney
3,130 PointsProgram.cs(13,28): error CS1056: Unexpected character `\0022'
I'm not sure why this error is being thrown. Can someone please advise?
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
Console.Write("Enter the number of times to print \"Yay!\": ");
int entry = Console.ReadLine();
while (counter == entry)
{
var counter = 0;
Console.Write(\"Yay!\");
counter =+ 1;
}
}
}
}
3 Answers
micram1001
33,833 PointsNeed to convert string to int. Also ("\"Yay!\"") output needs quotes on to begin and end.
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
Console.WriteLine("Enter the number of times to print \"Yay!\": ");
string entry = Console.ReadLine();
int totals = int.Parse(entry);
int counters = 0;
while(counters < totals)
{
Console.WriteLine("\"Yay!\"");
counters += 1;
}
}
}
}
micram1001
33,833 Pointstask 2:
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
Console.WriteLine("Enter the number of times to print \"Yay!\": ");
string entry = Console.ReadLine();
int totals = 0;
int counters = 0;
try
{
totals = int.Parse(entry);
}
catch(FormatException)
{
Console.Write("You must enter a whole number.");
}
while(counters < totals)
{
Console.WriteLine("\"Yay!\"");
counters += 1;
}
}
}
}
micram1001
33,833 Pointstask #3
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
Console.WriteLine("Enter the number of times to print \"Yay!\": ");
string entry = Console.ReadLine();
int totals = 0;
int counters = 0;
try
{
totals = int.Parse(entry);
}
catch(FormatException)
{
Console.Write("You must enter a whole number.");
}
while(counters < totals)
{
Console.WriteLine("\"Yay!\"");
counters += 1;
}
if (totals <= 0)
{
Console.Write("You must enter a positive number.");
}
}
}
}