VB.Net by API/System.Collections.Specialized/NameValueCollection — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 12:49, 26 мая 2010

NameValueCollection.Add

  
Imports System
Imports System.Collections
Imports System.Collections.Specialized

Public Class MainClass
    
    Shared Sub Main(ByVal args As String())
        Dim nvc As New NameValueCollection
        nvc.Add("Value 1", "Key 1")
        nvc.Add("Value 2", "Key 2")
        nvc.Add("Value 3", "Key 3")
        nvc.Add("Value 4", "Key 4")
        nvc.Add("Value 5", "Key 5")
        nvc.Add("Value 6", "Key 6")
        nvc.Add("Value 7", "Key 7")
        Dim values() As String
        For Each key As String In nvc.Keys
            Console.Write(key & ":")
            values = nvc.GetValues(key)
            For Each value As String In values
                Console.WriteLine("    " & value)
            Next value
        Next key
        Console.WriteLine()
        For Each key As String In nvc.Keys
            Console.WriteLine(key & ": " & nvc.Item(key))
        Next key
        
    End Sub
End Class


NameValueCollection.GetValues

  
Imports System
Imports System.Collections
Imports System.Collections.Specialized

Public Class MainClass
    
    Shared Sub Main(ByVal args As String())
        Dim nvc As New NameValueCollection
        nvc.Add("Value 1", "Key 1")
        nvc.Add("Value 2", "Key 2")
        nvc.Add("Value 3", "Key 3")
        nvc.Add("Value 4", "Key 4")
        nvc.Add("Value 5", "Key 5")
        nvc.Add("Value 6", "Key 6")
        nvc.Add("Value 7", "Key 7")
        Dim values() As String
        For Each key As String In nvc.Keys
            Console.Write(key & ":")
            values = nvc.GetValues(key)
            For Each value As String In values
                Console.WriteLine("    " & value)
            Next value
        Next key
        Console.WriteLine()
        For Each key As String In nvc.Keys
            Console.WriteLine(key & ": " & nvc.Item(key))
        Next key
        
    End Sub
End Class


NameValueCollection.Item

  
Imports System
Imports System.Collections
Imports System.Collections.Specialized

Public Class MainClass
    
    Shared Sub Main(ByVal args As String())
        Dim nvc As New NameValueCollection
        nvc.Add("Value 1", "Key 1")
        nvc.Add("Value 2", "Key 2")
        nvc.Add("Value 3", "Key 3")
        nvc.Add("Value 4", "Key 4")
        nvc.Add("Value 5", "Key 5")
        nvc.Add("Value 6", "Key 6")
        nvc.Add("Value 7", "Key 7")
        Dim values() As String
        For Each key As String In nvc.Keys
            Console.Write(key & ":")
            values = nvc.GetValues(key)
            For Each value As String In values
                Console.WriteLine("    " & value)
            Next value
        Next key
        Console.WriteLine()
        For Each key As String In nvc.Keys
            Console.WriteLine(key & ": " & nvc.Item(key))
        Next key
        
    End Sub
End Class


NameValueCollection.Keys

  
Imports System
Imports System.Collections
Imports System.Collections.Specialized

Public Class MainClass
    
    Shared Sub Main(ByVal args As String())
        Dim nvc As New NameValueCollection
        nvc.Add("Value 1", "Key 1")
        nvc.Add("Value 2", "Key 2")
        nvc.Add("Value 3", "Key 3")
        nvc.Add("Value 4", "Key 4")
        nvc.Add("Value 5", "Key 5")
        nvc.Add("Value 6", "Key 6")
        nvc.Add("Value 7", "Key 7")
        Dim values() As String
        For Each key As String In nvc.Keys
            Console.Write(key & ":")
            values = nvc.GetValues(key)
            For Each value As String In values
                Console.WriteLine("    " & value)
            Next value
        Next key
        Console.WriteLine()
        For Each key As String In nvc.Keys
            Console.WriteLine(key & ": " & nvc.Item(key))
        Next key
        
    End Sub
End Class