Created
April 23, 2012 08:32
-
-
Save hatelove/2469587 to your computer and use it in GitHub Desktop.
OrderedDictionary in .NET 3.5 and .NET 4.0 throw exception
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//這段程式碼,在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