.Net

how to read write data in dictionary using c# and VB.net

What is Dictionaries ?

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

 

[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);
}

mycodetips

Passionate about coding and software development holding 10+ Years of experience including 6+ years of experience on Mobile application Development.

More Posts