Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
Dictionary keys printing problem
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Javed Iqbal
10y
543
1
Reply
Why is this code printing the same 'key' once only?
Dictionary<int,string> dictionary = new Dictionary<int,string>();
var keys=new List<string>();
try
{
dictionary.Add(5, "javed");
dictionary.Add(5, "khan");
dictionary.Add(5, "javed");
}
catch (ArgumentException)
{
Console.WriteLine("Key/Value pair already used");
}
finally
{
foreach (int key in dictionary.Keys)
{
Console.WriteLine(key);
}
}
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Working with rating control in ajax toolkit
Import and Export Excel Files into SQL with C# ?