Question: Hello I have tried to follow learning on codeasy.net, I have reached chapter 4 where it asks this: 

Write a program that reads from the console three numbers each from the new line and then outputs the middle by the value of these three numbers. 

```
Example:
 >54
 >4456
 >2
 54

```

I have tried all the code I know as a beginner and it is still wrong. My current code is this:

```
using System;

namespace ConsoleInput
{
public class TheMiddle
{
    public static void Main(string[] args)
    {
          int a = int.Parse(Console.ReadLine());
          int b = int.Parse(Console.ReadLine());
          int c = int.Parse(Console.ReadLine()); 

       if (a < b && c < b)
       Console.WriteLine(a);
       if (a < b && b < c)
       Console.WriteLine(b);
       if (c < b && a < c)
       Console.WriteLine(c);
       if (a < b && c > b )
       Console.WriteLine(a);
       else
       if (a > b && c > a)
       Console.WriteLine(a);
       if (a > b && b > c)
       Console.WriteLine(b);
      if (c > b && b > a)
      Console.WriteLine(a);
       if (b > a && c > a)
       Console.WriteLine(c);

    }
 }
}

```

Answer: 
```
using System;

namespace ConsoleInput
{
public class TheMiddle
{
    public static void Main(string[] args)
    {
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());
        int c = int.Parse(Console.ReadLine());

        int result;
        if (a < b)
        {
            if (c < a)
                result = a;
            else if (c > b)
                result = b;
            else
                result = c;
        }
        else
        {
            if (c < b)
                result = b;
            else if (c > a)
                result = a;
            else
                result = c;
        }

        Console.WriteLine(result);
    }
  }
}

```

this is the answer.
You can do this just by sorting your values and taking middle:

```
var list = new List<int>();
list.Add(a);
list.Add(b);
list.Add(c);
list.Sort();
var middleValue = list[list.Count/2];

```