Thursday, February 18, 2010

Should ArrayList Be Deprecated?

I came across a poster on the Microsoft Forums the other day, who was asking a question about the .NET ArrayList. Whenever I hear the word, I cringe. Since the advent of generics, I've never once used ArrayList.

That being said, some of you may have, so I'd like to hear what you think.

Should ArrayList be deprecated, perhaps with a deprecation message that points the user to List?

Feel free to vote in the poll on the right, or leave your comments below.

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.