Weather forecast printing I receive a weather forecast for 5 days, but in 3 hours intervals.
This classes represent the weather forecast:

public class Forecast : ILocation
{
    [JsonIgnore()]
    public string City { get; set; }
    [JsonIgnore()]
    public string Country { get; set; }
    [JsonProperty("list")]
    public IList&lt;WeatherTimePoint&gt; TimePoints { get; set; }
}
public class WeatherTimePoint
{
    [JsonProperty("dt")]
    [JsonConverter(typeof(UnixTimeStampConverter))]
    public DateTime TimePoint { get; set; }
    [JsonProperty("main")]
    public ClimaticData ClimaticData { get; set; }
    [JsonProperty("weather")]
    public IList&lt;Weather&gt; Weather { get; set; }
    [JsonProperty("wind")]
    public Wind Wind { get; set; }
    [JsonIgnore()]
    public Units Units { get; set; }
}


This method prints the forecast:

 static void PrintForecast(Forecast forecast, int days)
    {
        days = days &gt; 5 ? 5 : days;
        DateTime printDate = DateTime.Now.Date;
        for (int i = 0; i &lt; days; i++)
        {
            printDate = printDate.AddDays(1);
            ChangeColor(ConsoleColor.Magenta);
            Console.WriteLine("== Day {0} ==", printDate.ToLongDateString());

            var timePointsDuringtDay = forecast.TimePoints.Where((weatherTimePoint) =&gt; weatherTimePoint.TimePoint.Date == printDate);
            for(int hour = 6; hour  &lt;= 21 ; hour = hour + 3)
            {
                var weatherAtHour = timePointsDuringtDay.SingleOrDefault((weatherTimePoint) =&gt; weatherTimePoint.TimePoint.Hour == hour);
                if (weatherAtHour != null)
                {
                    ChangeColor(ConsoleColor.DarkCyan);
                    Console.Write("{0}/", hour);
                    ChangeColor(ConsoleColor.DarkGreen);
                    Console.Write("{0}({1})/",weatherAtHour.Weather[0].Condition, weatherAtHour.Weather[0].Description);
                    ChangeColor(ConsoleColor.Red);
                    Console.Write("{0}{1}",weatherAtHour.ClimaticData.Temperature, UnitsHelper.GetUnit(forecast.Units, UnitsHelper.WeatherField.Temperature));
                    Console.WriteLine();
                }   
            }
            ChangeColor(ConsoleColor.White);
            Console.WriteLine("Average humidity:{0}%", timePointsDuringtDay.Average((weatherTimePoint) =&gt; weatherTimePoint.ClimaticData.Humidity));
            Console.WriteLine("Average pressure:{0} hPa", timePointsDuringtDay.Average((weatherTimePoint) =&gt; weatherTimePoint.ClimaticData.Pressure));
        }
    }


I thought it's quite unreadable. I am searching for any suggestion to improve the printing method. (ILocation is just a interface, that defines city and country properties. This is irrelevant for this method ;) )
To save a few lines create a Style enum first:

enum Style 
{
    Header,
    Hour,
    Condition,
    Temperature
}


Then assign each style a color:

static Dictionary&lt;Style, ConsoleColor&gt; _styles = new Dictionary&lt;Style, ConsoleColor&gt;
{
    [Style.Header] = ConsoleColor.Magenta,
    ...
}


Use overloading to encapsulate the styling logic like this:

private static void Print(Style style, string format, params object[] args)
{
    Console.ForegroundColor = _styles[style];
    Console.Write(format, args);
    Console.ResetColor();   
}

private static void PrintLine(Style style, string format, params object[] args)
{
    Print(style, format, args);
    Console.WriteLine();
}


I think it's a good idea to stick to the Print &amp; PrintLine convention like the console does it.

Then you can turn this:


 ChangeColor(ConsoleColor.Magenta);
 Console.WriteLine("== Day {0} ==", printDate.ToLongDateString());



into:

Print(Style.Header, "== Day {0} ==", printDate.ToLongDateString());


You can go even further and create a special method called PrintHeader and do all the magic there like so:

PrintHeader(printDate)
{
    Print(Style.Header, "== Day {0} ==", printDate.ToLongDateString());
}


This way your printing becomes even cleaner and you can manipulate the header separately.

The same applies for other cases.




 DateTime printDate = DateTime.Now.Date;
 for (int i = 0; i &lt; days; i++)
 {
     printDate = printDate.AddDays(1);
     ...
 }



I would remove the helper above the loop and write:

 for (int i = 0; i &lt; days; i++)
 {
     var printDate = DateTime.Now.Date.AddDays(i + 1);
     ...
 }


Magic numbers

You should replace all those 5, 6, 21 etc with constants and give them proper names. I have no idea what they mean. You in few week will wonder too why such numbers.




 if (weatherAtHour != null)    {
 }



make it 

if (weatherAtHour == null) { continue; }


to reduce nesting.



for (int hour = 6; hour &lt;= 21; hour = hour + 3)

I would encapsulate this logic in a method like this:

private static IEnumerable&lt;int&gt; Hours()
{
    for (int hour = 6; hour &lt;= 21; hour = hour + 3)
    {
        yield return hour;
    }
}


Then in your weather print you can use link with ease:

var weathersAtHour = 
    Hours()
    .Select(hour =&gt; timePointsDuringtDay.SingleOrDefault(weatherTimePoint =&gt; weatherTimePoint.TimePoint.Hour == hour))
    .Where(x =&gt; x != null);

foreach (var weatherAtHour in weathersAtHour)
{
   ...
}