Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 334313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:02:33+00:00 2026-05-12T10:02:33+00:00

I have a bunch of classes that each have a property called Sequence. This

  • 0

I have a bunch of classes that each have a property called Sequence. This property is implemented from an interface called ISequenced. For this example lets call one of these classes A.
When I have a List(of A), I want to be able to sort them using the standard List.Sort(addressof delegate) where the delegate is a standard function that takes in two ISequenced objects and compares their sequence numbers and returns a boolean flag, rather than declaring a function for each individual class that implements ISequenced.

E.g.

Dim li as List(of A) = GetValues()

li.Sort(addressof SortBySeq)

...

Public Function SortBySeq(ByVal ob1 as ISequenced, ByVal ob2 as ISequenced) as Boolean
   return ob1.Sequence.CompareTo(ob2.Sequence)
End If

EDIT: Using the above gives me the following error:

“Overload resolution failed because no
accessible ‘Sort’ can be called with
these arguments:
‘Public Sub Sort(comparison As System.Comparison(Of A))’: Option
Strict On does not allow narrowing in
implicit type conversions between
method ‘Public Function SortBySeq(ob1
As ISequenced, ob2 As ISequenced) As
Integer’ and delegate ‘Delegate
Function Comparison(Of A)(x As A, y As
A) As Integer’.
‘Public Sub Sort(comparer As System.Collections.Generic.IComparer(Of
A))’: ‘AddressOf’ expression cannot be
converted to
‘System.Collections.Generic.IComparer(Of
A)’ because
‘System.Collections.Generic.IComparer(Of
A)’ is not a delegate type.”

How would I declare the function in order to do this (if it is even possible in VB.NET?

Thanks,
Dane.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:02:33+00:00Added an answer on May 12, 2026 at 10:02 am

    Didn’t need to implement IComparer in the end as I was only comparing decimals. Turns out that .NET 3.5 added at least some covariance abilities with delegates so I’ve upgraded to that and the example I gave above seems to work fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say that I have a table containing users . Each row in that
I have a bunch of classes in a basic (and badly coded!) game engine
I have a base class, SpecialClass . Lots of other classes inherit from it,
I need some help with defining a dynamic method. Basically, I have many classes
I'm writing a bunch of classes in PHP for the server-side portion of a
I'm building an iPhone app that aggregates data from several different data sources and
This is another one of my I think it's not possible but I need
Say I'm modeling a school, so I have 2 Entities: Student and Class. For
I have an autocomplete on my site where a user enters a class at
I am using the excellent org.as3commons.reflect and org.as3commons.lang libraries and have hit a snag.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.