Does the below approach work?
Imports System.Reflection
If GetType(IComparable(Of T)).GetTypeInfo().IsAssignableFrom(GetType(T).GetTypeInfo()) Then
comparer = Comparer(Of T).[Default]
End If
Windows Store Developer Solutions #WSDevSol || Want more solutions? See our blog, http://aka.ms/t4vuvz
Progress! The first line "If..." seems to be correct, thanks!
But there is still a problem with the second line:
Dim comparerx As IComparer(Of T) = Me.m_comparer
If comparerx Is Nothing Then
If GetType(IComparable(Of T)).GetTypeInfo().IsAssignableFrom(GetType(T).GetTypeInfo()) Then
comparerx = Comparer(Of T).[Default]
End If
Public Property Comparer() As IComparer(Of T)
Get
Return Me.m_comparer
End Get
Set(value As IComparer(Of T))
Me.m_comparer = value
End Set
End Property
Now I just get an error on:
comparerx = Comparer(Of T).[Default]
(Comparer has no type parameters).
Removing the parameter doesn't help. What is the correct syntax here?
The C# code being converted is:
comparer = Comparer<T>.Default;
Any ideas?
I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.