You are passing object to the Console.WriteLine(item)
instead of passing the string. Console.WriteLine
invokes ToString()
method of that object that by default returns namespace+class name. You can override this behavior like next:
public class City //class
{
public string CityName { get; set; }
public int Temperature { get; set; }
public City(string name, int temp)//konstruktor
{
this.CityName = name;
this.Temperature = temp;
}
public override string ToString()
{
return string.Format("{0} {1}", CityName, Temperature);
}
}
Or you can use another overload of WriteLine
method:
Console.WriteLine("{0} {1}", item.CityName, item.Temperature);