• Home
  • Basics
  • DSA
  • MAD
  • Concept
  • Practice
  • Misc
    • Tips
    • QA’s
    • Misc
  • Course
  • Home
  • Basics
  • DSA
  • MAD
  • Concept
  • Practice
  • Misc
    • Tips
    • QA’s
    • Misc
  • Course
  • #News
  • #APPS
  • #Apple WWDC
  • #Google I/O
  • #Microsoft Ignite
  • #Let’s Talk
  • #Advertise

MyCodeTips mycodetips-newlogocopy1

  • Home
  • Basics
  • DSA
  • MAD
  • Concept
  • Practice
  • Misc
    • Tips
    • QA’s
    • Misc
  • Course
.Net

Dictionary, How to read-write data in using C# and VB.net

Dictionary, How to read-write data in using C# and VB.net

What is Dictionaries ?

Dictionary is a collection object which is used to store data in key and value pairs. In this, object Key values must be always unique and it won’t accept any null or duplicate values because we use keys to identify values stored in dictionary objects but values can be duplicated or we can set null values also.

Dictionaries are collections that are meant to store lists of key/value pairs to allow the lookup of values based on a key.

The Dictionary collection is a part of generic collections so to use Dictionary object in our applications we need to add the following namespace in our applications.

C# Dictionary class is a generic collection of keys and values pair of data. The Dictionary class is defined in the System.Collections.A generic namespace is a generic class and can store any data type in a form of keys and values. Each key must be unique in the collection.

[VB.Net]

Private Sub mycodetips()
Dim mycodetips As New Hashtable()
‘The first method.
mycodetips.Add(“MN145098”, “Mehran,Jn”)
‘The second method.
mycodetips(“MN18454”) = “Arman,Nas”
End Sub

[C#]

private void CreateHashTable()
{
Hashtable mycodetips = new Hashtable();
//The first method.
mycodetips.Add(“MN145098”, “Mehran,Jn”);
//The second method.
mycodetips[“MN18454”] = “Arman,Nas”;
}

The way you can read the data

[VB.Net]

For Each Item As DictionaryEntry In mycodetips
Console.WriteLine(Item.Value)
Next

[C#]

foreach (DictionaryEntry Item in mycodetips) {
Console.WriteLine(Item.Value);
}

  • Click to share on Reddit (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • More
  • Click to share on Pocket (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
Written by Ranjan - June 6, 2013 - 1617 Views
Tags | C#, VB.Net
AUTHOR
Ranjan

This website is basically about of what we learnt from my years of experience as a software engineer on software development specifically on mobile application development, design patterns/architectures and its changing scenarios, security, troubleshooting, tools, tips&tricks and many more.

You Might Also Like

mycodetips-newlogo2

How to add watermark to an image in c#

June 8, 2013
Next Post
Previous Post

Support us

Subscribe for updates

Join 8,278 other subscribers

Latest Posts

  • Exploring Single Point Failure
    Exploring Single Point Failures: Causes and Impacts
  • primitive-datatypes-new
    Exploring the Pros and Cons of Primitive Data Types
  • best practice clean code
    Essential Coding Standards and Best Practices for Clean Code
  • YT-Featured-Templates--lld
    What Business Problems Solves in Low Level Design (LLD)
  • SRP-SingleResopnsibility
    SRP : Single Responsibility Principle in Swift and Objective-C
whiteboard

Whiteboard(PRO)

whiteboard

Whiteboard(lite)

alphabets

Kids Alphabet

do2day

Do2Day

  • #about
  • #myapps
  • #contact
  • #privacy
  • #Advertise
  • #myQuestions

Android Database Interview IOS IOSQuestions Javascript Objective-c Programming Swift Tips&Tricks Web Wordpress

  • Exploring Single Point Failures: Causes and Impacts
  • Exploring the Pros and Cons of Primitive Data Types
  • Essential Coding Standards and Best Practices for Clean Code
MyCodeTips

©mycodetips.com

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.