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 trialElizabeth Pasek-Allen
1,420 PointsProgram.cs(16,25): error CS0019: Operator `-' cannot be applied to operands
using System;
namespace Treehouse
{
class Program
{
static void Main()
{
//Prompt the user for minuets excerised
Console.Write("Enter how many times you excercised: ");
string entry = Console.ReadLine();
//Add minuets excercied to total
//Display total minuets excercised to the screnn
Console.WriteLine("You've entered " - entry + " minuets");
}
}
}
2 Answers
Brendon Butler
4,254 PointsI program in java, so I don't know how different C# is, but you can't subtract strings from each other. It looks like you'd want to replace your minus sign with a plus sign in this line:
Console.WriteLine("You've entered " - entry + " minuets");
so that it looks like this: (also it looks like you have a spelling error in "minutes"
Console.WriteLine("You've entered " + entry + " minutes");
Elizabeth Pasek-Allen
1,420 PointsThanks! Oh yeah I spelled minutes wrong too... but hmmm that still doesn't solve it...
I'm still getting
Program.cs(16,25): error CS0019: Operator -' cannot be applied to operands of type
string' and `string'
Justin Horner
Treehouse Guest TeacherHello Elizabeth Pasek-Allen,
The answer Brendon Butler provided should fix the issue. I modified and compiled the code to confirm. If you're still getting this error, try using the following code.
using System;
namespace Treehouse
{
class Program
{
static void Main()
{
//Prompt the user for minuets excerised
Console.Write("Enter how many times you excercised: ");
string entry = Console.ReadLine();
//Add minuets excercied to total
//Display total minuets excercised to the screnn
Console.WriteLine("You've entered " + entry + " minuets");
}
}
}
I hope this helps.
Elizabeth Pasek-Allen
1,420 PointsElizabeth Pasek-Allen
1,420 PointsI'm not sure what I am doing wrong.
I keep getting this error Program.cs(16,25): error CS0019: Operator
-' cannot be applied to operands of type
string' and `string'Compilation failed: 1 error(s), 0 warnings