Question: So, first of all, I am a beginner and this problem must be super simple, but I just don't find it. So the problem is, I have a small txt, containing fruits and its amounts:

```
Apple 26
Banana 55
Pear 12
Orange 32
Watermelon 81
Grapefruit 30

```

And I add these values in a list, but it outputs (in my opinion) the namespace's name. I guess this is some "property access" issue, but I don't know how to solve it.

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace practice
{
    class Fruits
    {

        string fruit { get; set; }
        int amount { get; set; }

        public Fruits(string a, int b)
        {
            fruit = a;
            amount = b;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            List<Fruits> data = new List<Fruits>();
            StreamReader str_R = new StreamReader("list.txt");
            while (!str_R.EndOfStream)
            {
                String[] line = str_R.ReadLine().Split(' ');
                data.Add(new Fruits(line[0], Convert.ToInt32(line[1])));

            }

            foreach (var x in data)
            {
                Console.WriteLine(x);
            }

            Console.ReadKey();

        }
    }
}

```

Output:

```
practice.Fruits
practice.Fruits
practice.Fruits
practice.Fruits
practice.Fruits
practice.Fruits

```

I want the actual values of the list as output.

Answer: 
The base class of `Fruits` class is [`Object`](https://msdn.microsoft.com/en-us/library/system.object.tostring(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-4) class, when you call an **instance** of a class by default it will return the `ToString()` method.  
 the `ToString()` method of object returns the type of this object (the namespace).  
 the `ToString()` method is [`Virtual`](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/virtual) (can be overridden by any class that inherits it) so you can override it:

```
class Fruits
{

    string fruit { get; set; }
    int amount { get; set; }

    public Fruits(string a, int b)
    {
        fruit = a;
        amount = b;
    }

    public override string ToString()
    {
        return string.Format("Fruit: {0} Ammount: {1}", fruit, amount);
    }
}

```

Also, you can always do that:

```
foreach (var x in data)
{
    Console.WriteLine(string.Format("Fruit: {0} Ammount: {1}", x.fruit, x.amount));
}

```
This is normal behavior. If given anything but a String, Console.WriteLine() will call ToString() on it. 

Object.ToString() will simply output the class name, unless it is overridden.

You either need to override ToString() for Fruits: 

```
public override string ToString(){
  return fruit;
}

```

Or outpoint x.fruit and x.amount explicitly.

```
foreach (var x in data)
{
    Console.WriteLine(x.fruit);
}

```