vamsivanka
vamsivanka

Reputation: 792

twitter oauth icomparer error

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

Upvotes: 0

Views: 235

Answers (3)

Don
Don

Reputation: 11

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

Upvotes: 1

JB_STC
JB_STC

Reputation: 1

    Public Function Compare(ByVal x As OAuth.QueryParameter, ByVal y As OAuth.QueryParameter) As Integer _
    Implements IComparer(Of QueryParameter).Compare

Upvotes: -1

Andrew Arnott
Andrew Arnott

Reputation: 81821

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. :)

Upvotes: 1

Related Questions