Imports System.Runtime.CompilerServices

Namespace Extensiones
    Public Module NameValueCollection

        <Extension()>
        Public Function ToPairs(collection As Specialized.NameValueCollection) As IEnumerable(Of KeyValuePair(Of String, String))
            If collection Is Nothing Then
                Throw New ArgumentNullException("collection")
            End If

            Return collection.Cast(Of String)().[Select](Function(key) New KeyValuePair(Of String, String)(key, collection(key)))
        End Function

    End Module
End Namespace
