Question : Anonymous Delegate in VB.NET

Hi,

I am trying to convert C# code to VB.NET Code, but facing some trivial problems. I've more experience on C#, and hence not able to write the attached code to VB.NET. Please help as this code involves Anonymous Delegates.

1:
2:
3:
4:
5:
6:
sortedExtensions.Sort(delegate(SortedExtension e1, SortedExtension e2)
				{
					if (e1.Priority == e2.Priority)
						return string.CompareOrdinal(e1.Name, e2.Name);
					return e1.Priority.CompareTo(e2.Priority);
				});

Answer : Anonymous Delegate in VB.NET

The syntax still looks really weird to me...  =)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim sortedExtensions As New List(Of SortedExtension)

        sortedExtensions.Sort(Function(e1 As SortedExtension, e2 As SortedExtension) As Integer
                                  If e1.Priority = e2.Priority Then
                                      Return String.CompareOrdinal(e1.Name, e2.Name)
                                  Else
                                      Return e1.Priority.CompareTo(e2.Priority)
                                  End If
                              End Function)
    End Sub
Random Solutions  
 
programming4us programming4us