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 trialNicholas Inverno
5,430 PointsI need help
I keep getting this error:
Program.cs(27,41): error CS1525: Unexpected symbol values'
Program.cs(27,50): error CS1026: Unexpected symbol
,', expecting )'
Program.cs(27,71): error CS1026: Unexpected symbol
)', expecting `)'
Compilation failed: 3 error(s), 0 warnings
I'm not sure what I am doing wrong. Can anyone help me?
using System;
using System.IO;
namespace Treehouse.CodeChallenges
{
public class Program
{
public static void Main(string[] arg)
{
}
public static WeatherForecast ParseWeatherForecast(string[] values)
{
var weatherForecast = new WeatherForecast();
weatherForecast.WeatherStationId = values[0];
DateTime timeOfDay;
if (DateTime.TryParse(values[1], out timeOfDay))
{
weatherForecast.TimeOfDay = timeOfDay;
}
Condition condition;
if (Enum.TryParse(values[2], out condition))
{
weatherForecast.Condition = condition;
}
var TryParse = new ParseWeatherForecast();
if (int.TryParse(Temperature values[3], out weatherForecast)
{
weatherForcast.Temperature = temperature;
}
return weatherForecast;
}
}
}
using System;
/* Sample CSV Data
weather_station_id,time_of_day,condition,temperature,precipitation_chance,precipitation_amount
HGKL8Q,06/11/2016 0:00,Rain,53,0.3,0.03
HGKL8Q,06/11/2016 6:00,Cloudy,56,0.08,0.01
HGKL8Q,06/11/2016 12:00,PartlyCloudy,70,0,0
HGKL8Q,06/11/2016 18:00,Sunny,76,0,0
HGKL8Q,06/11/2016 19:00,Clear,74,0,0
*/
namespace Treehouse.CodeChallenges
{
public class WeatherForecast
{
public string WeatherStationId { get; set; }
public DateTime TimeOfDay { get; set; }
public Condition Condition { get; set; }
public int Temperature { get; set; }
}
public enum Condition
{
Rain,
Cloudy,
PartlyCloudy,
PartlySunny,
Sunny,
Clear
}
}
1 Answer
Steven Parker
231,268 PointsIt looks like you did more than the challenge asked.
Justin makes a good point, but that entire section of code is not part of the tasks asked by the challenge. In fact, both files have things added to them that are not part of this challenge.
I tried the challenge myself, and cut only the parts above that related to the challenge and pasted them in, and it passed just fine.
It looks like you just pasted in something from another question on a similar, but somewhat different challenge. That's not only a bad idea because it's likely to introduce errors as you had here, but you miss a valuable part of the learning experience that you would get by constructing the answer on your own.
Justin Molyneaux
13,329 PointsJustin Molyneaux
13,329 PointsHey Nicholas,
I think you are getting the error because you are missing a ")" near line 27 of your code:
YOUR CODE:
TO FIX add a ")" right at the very end like this:
if (int.TryParse(Temperature values[3], out weatherForecast))
Try that and you should get a successful compilation.