0

我正在尝试将此代码从 csharp 转换为 vb。使用免费 csharp 到 vb 转换器的所有孩子,但出现错误。请让知道是否有人以前解决过这个问题。

错误:

类 'QueryParameterComparer' 必须为接口 'System.Collections.Generic.IComparer(Of QueryParameter)' 实现 'Function Compare(x As OAuthBase.QueryParameter, y As OAuthBase.QueryParameter) As Integer'

来自 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);
            }
        }

    }

到vb代码

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
4

3 回答 3

1

尝试OAuthBase.在您的每个参数类型前面粘贴?

或者使用 OAuth 库,例如DotNetOpenAuthLinqToTwitter,这样您就不必担心了。:)

于 2009-10-19T14:05:48.943 回答
1

在函数声明的末尾添加这个

实现 IComparer(Of QueryParameter).Compare

那么它是:

    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
于 2010-10-13T19:26:56.683 回答
-1
    Public Function Compare(ByVal x As OAuth.QueryParameter, ByVal y As OAuth.QueryParameter) As Integer _
    Implements IComparer(Of QueryParameter).Compare
于 2010-09-23T19:09:34.913 回答