Name Value Collecion in VB.net
By: Issac
There is one datastructure in .net that is very similar to Hash table it is called as Name Value collection, which is used to store data in a unique format Name, Value format, Hash table stores in Key, value format but NameValueCollection can hold more than one value for a reference key.
Adding new pairs
Add (ByVal name As String, ByVal value As String)
Add ("Rudran","80")
Get the value of corresponding Key
GetValues(ByVal name As String) As String()
String values() = GetValues("Rudran")
Imports System.Collections.Specialized
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim markStatus As New NameValueCollection
Dim key As String
Dim values() As String
markStatus.Add("A+", "80")
markStatus.Add("First Class", "60")
markStatus.Add("Average", "50")
markStatus.Add("Pass", "40")
For Each key In markStatus.Keys
values = markStatus.GetValues(key)
For Each value As String In values
MsgBox(key & " - " & value)
Next value
Next key
End Sub
End Class
When you run this code you will get a key/value set which can be check the mark status of the students.
Archived Comments
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Using Resume Next and Resume Line in VB.net
Using On Error GoTo 0 in VB.net
Getting an Exception's Number and Description in VB.net
Raising an Exception Intentionally in VB.net
Exception Filtering in the Catch Block in VB.net
Using Multiple Catch Statements in VB.net
Throwing an Exception in VB.net
Throwing a Custom Exception in VB.net
Changes in Controls from VB6 to VB.net
Unstructured Exception Handling in VB.net