TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
0
328.1k
ContainsKey
Oct 1 2013 2:32 PM
This program is given in the following website. Please explain why o/p is 1000, which is coming from Console.WriteLine(dictionary["mac"]);. Problem is highlighted.
http://www.dotnetperls.com/containskey
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
// Create Dictionary with two key value pairs.
var dictionary = new Dictionary<string, int>(){{"mac", 1000}, {"windows", 500}};
// Use ContainsKey method.
if (dictionary.ContainsKey("mac") == true)
{
Console.WriteLine(dictionary["mac"]);
// <-- Is executed
}
// Use ContainsKey method on another string.
if (dictionary.ContainsKey("acorn"))
{
Console.WriteLine(false); // <-- Not hit
}
Console.ReadKey();
}
}
//1000
Reply
Answers (
8
)
VB .Net Application
how to sort string without using array.sort