100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Everything you need to know for Dictionary in C#. R151,00   Add to cart

Class notes

Everything you need to know for Dictionary in C#.

 2 views  0 purchase

Provides the basics of understanding and implementing a Dictionary in C#.

Preview 1 out of 3  pages

  • March 1, 2022
  • 3
  • 2021/2022
  • Class notes
  • None
  • All classes
All documents for this subject (1)
avatar-seller
21615442
C#

Dictionary.

Difference between an array and a dictionary.
An array stores a list of objects and a dictionary store key-value pair.



Key-value pair (KVP).
Is a set of two linked data items, a key which is a unique identifier for some item
of data, and the value.

Example.

Sam,9712



Maps is the concept that provides the functionality to map the value with the key
inside the dictionary.



To initialise the basic commands in c# must have the below.

using System.Collections.Generic;



Dictionary < string, => This initialises the dictionary value and classes it as a
string.

string > phonebook = new Dictionary < string, => This sets the Dictionary value to
be named as phonebook.

string > (); => This closes the initialisation of dictionary.



Storing the values into the Dictionary (in this case the dictionary is treated as an array).

//Create a dictionary and add names to the dictionary.

Dictionary<string, int> names = new Dictionary<string, int>();

names.Add("John Doe",45);
names.Add("Sammy", 50);
names.Add("Harry styles", 18);

Console.WriteLine("Sammy is "+ names["Sammy"]+ " years old.");


//Create a dictionary with a size to it.
Dictionary<int, double> numbers = new Dictionary<int,double>(5);
numbers.Add(1, 1000);
numbers.Add(2, 50);
numbers.Add(3, 800);
numbers.Add(4, 4);
numbers.Add(5, 900);

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through EFT, credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying this summary from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller 21615442. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy this summary for R151,00. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

67474 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy summaries for 14 years now

Start selling
R151,00
  • (0)
  Buy now