Tuesday, February 16, 2010

What's wrong with this picture?


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication95
{
class Program
{
private List<string> _items = new List<string>();

public List<string> Items
{
get { return _items.ToList(); }
set { _items = value; }
}
static void Main(string[] args)
{
Program program = new Program();
program.Items = new List<string> { "One", "Two", "Three" };
program.Items.Add("Four");
foreach (var item in program.Items)
Console.WriteLine(item);
Console.ReadLine();
}
}
}


What do you think this code will do?

It may not be what you think.