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 inter开发者_运维问答face '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
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. :)
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
Public Function Compare(ByVal x As OAuth.QueryParameter, ByVal y As OAuth.QueryParameter) As Integer _
Implements IComparer(Of QueryParameter).Compare
精彩评论