tags:

views:

60

answers:

3

I am trying to convert this code from csharp to vb. Used all kids of free csharp to vb converter but getting an error. please let know if anyone has solved this problem before.

error:

Class 'QueryParameterComparer' must implement 'Function Compare(x As OAuthBase.QueryParameter, y As OAuthBase.QueryParameter) As Integer' for interface 'System.Collections.Generic.IComparer(Of QueryParameter)'

from c#code:

protected class QueryParameterComparer : IComparer<QueryParameter>
    {

        public int Compare(QueryParameter x, QueryParameter y)
        {
            if (x.Name == y.Name)
            {
                return string.Compare(x.Value, y.Value);
            }
            else
            {
                return string.Compare(x.Name, y.Name);
            }
        }

    }

to vb code

Protected Class QueryParameterComparer
        Implements IComparer(Of QueryParameter)

        #Region "IComparer Members"

        Public Function Compare(ByVal x As QueryParameter, ByVal y As QueryParameter) As Integer
            If x.Name = y.Name Then
                Return String.Compare(x.Value, y.Value)
            Else
                Return String.Compare(x.Name, y.Name)
            End If
        End Function

        #End Region
    End Class
+1  A: 

Try sticking OAuthBase. in front of each of your parameter types?

Or use an OAuth library such as DotNetOpenAuth or LinqToTwitter so you don't have to worry about it. :)

Andrew Arnott
oAuthBase worked. Thank you
vamsivanka
i did this before, but i have to add to Implement IComparer(Of oAuthBase.QueryParameter)
vamsivanka
A: 
    Public Function Compare(ByVal x As OAuth.QueryParameter, ByVal y As OAuth.QueryParameter) As Integer _
    Implements IComparer(Of QueryParameter).Compare
JB_STC
A: 

Add this at the end of the Function declaration

Implements IComparer(Of QueryParameter).Compare

so then it's:

    Public Function Compare(ByVal x As QueryParameter, ByVal y As QueryParameter) As Integer Implements IComparer(Of QueryParameter).Compare
        If (x.Name = y.Name) Then
            Return String.Compare(x.Value, y.Value)
        Else
            Return String.Compare(x.Name, y.Name)
        End If
    End Function
Don

related questions