C # to VB.net conversion won't compile <param name = "x"
I cannot figure out how to convert this code from C # to VB.net. It says: no argument is specified for the 'y parameter in the calling code below.
Any suggestions?
thank
Calling CODE:
list.Sort(Utility.CompareContactListsBySortOrder) - error here in VB
CODE:
/// <summary>
/// Defines the compare criteria for two Contact List instances
/// </summary>
/// <param name="x">Contact List to be compared</param>
/// <param name="y">Contact List to be compared</param>
/// <returns></returns>
public static int CompareContactListsBySortOrder(ContactList x, ContactList y)
{
if (x.SortOrder.HasValue && y.SortOrder.HasValue)
{
return x.SortOrder.Value.CompareTo(y.SortOrder.Value);
}
return 0;
}
''' <summary>
''' Defines the compare criteria for two Contact List instances
''' </summary>
''' <param name="x">Contact List to be compared</param>
''' <param name="y">Contact List to be compared</param>
''' <returns></returns>
Public Shared Function CompareContactListsBySortOrder(ByVal x As ContactList, ByVal y As ContactList) As Integer
If x.SortOrder.HasValue AndAlso y.SortOrder.HasValue Then
Return x.SortOrder.Value.CompareTo(y.SortOrder.Value)
End If
Return 0
End Function
Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
target = value
Return value
End Function
+2
user32183
source
to share
2 answers
list.Sort(AddressOf Utility.CompareContactListsBySortOrder)
In VB, you use an operator AddressOf
to accept the address of a method to create a delegate. In C #, you just specify the name of the method.
+3
Mehrdad afshari
source
to share
you need to change it to: list.Sort (AddressOf Utility.CompareContactListsBySortOrder)
0
Joe caffeine
source
to share