Skip to content

Instantly share code, notes, and snippets.

@hatelove
Created April 23, 2012 08:32
Show Gist options
  • Save hatelove/2469587 to your computer and use it in GitHub Desktop.
Save hatelove/2469587 to your computer and use it in GitHub Desktop.
OrderedDictionary in .NET 3.5 and .NET 4.0 throw exception
//這段程式碼,在4.0裡面會出錯,在3.5不會出錯。
class Program
{
static void Main(string[] args)
{
var o = new OrderedDictionary();
for (int i = 0; i < 3; i++)
{
o.Add(i, string.Format("{0}_{1}", i.ToString(), "yahoo"));
}
foreach (DictionaryEntry item in o)
{
o[item.Key] = DateTime.Now.ToString();
}
Console.WriteLine("no exception");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment