
Scott George
19,060 PointsStuck on question No.1 I'm not getting an error, but there is no out put, just a blank page where the results should be.
I'm not getting an error, but there is no out put, just a blank page where the results should be. Thanks for any help
using System;
using System.IO;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Treehouse.CodeChallenges
{
public class Program
{
public static void Main(string[] arg)
{
}
public static void SerializeWeatherForecasts(List<WeatherForecast> serializeWeatherForecasts,string fileName)
{
var weatherForecasts = new List<WeatherForecast>();
}
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;
}
int temperature;
if (int.TryParse(values[3], out temperature))
{
weatherForecast.Temperature = temperature;
}
double precipitation;
if (double.TryParse(values[4], out precipitation))
{
weatherForecast.PrecipitationChance = precipitation;
}
if (double.TryParse(values[5], out precipitation))
{
weatherForecast.PrecipitationAmount = precipitation;
}
return weatherForecast;
}
public static List<WeatherForecast> DeserializeWeather(string fileName)
{
var weatherForecasts = new List<WeatherForecast>();
using (var reader = new StreamReader(fileName))
using (var jsonReader = new JsonTextReader(reader))
{
var serializer = new JsonSerializer();
weatherForecasts = serializer.Deserialize<List<WeatherForecast>>(jsonReader);
}
return weatherForecasts;
}
}
}
using System;
using Newtonsoft.Json;
namespace Treehouse.CodeChallenges
{
public class WeatherForecast
{
[JsonProperty(PropertyName = "weather_station_id")]
public string WeatherStationId { get; set; }
[JsonProperty(PropertyName = "time_of_day")]
public DateTime TimeOfDay { get; set; }
public Condition Condition { get; set; }
public int Temperature { get; set; }
[JsonProperty(PropertyName = "precipitation_chance")]
public double PrecipitationChance { get; set; }
[JsonProperty(PropertyName = "precipitation_amount")]
public double PrecipitationAmount { get; set; }
}
public enum Condition
{
Rain,
Cloudy,
PartlyCloudy,
PartlySunny,
Sunny,
Clear
}
}
1 Answer

Allan Clark
10,806 Points'weatherForecasts' has to be the name of your parameter. The REPL is pretty particular on some of the naming. Try this:
public static List<WeatherForecast> forecasts;
public static void Main(string[] arg)
{
}
public static void SerializeWeatherForecasts(List<WeatherForecast> weatherForecasts,string fileName)
{
forecasts = new List<WeatherForecast>();
}
Tyler B
5,774 PointsTyler B
5,774 PointsTo clarify this is when you hit the check work button or the preview button?