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 5961441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:57:55+00:00 2026-05-22T18:57:55+00:00

I need type parameter overloading as such: Public Class Map(Of TKey, TValue) Public Class

  • 0

I need type parameter overloading as such:

Public Class Map(Of TKey, TValue)

Public Class Map(Of TKey As IEquatable(Of TKey), TValue)

so that i can New Map(Of Human) and the compiler will automatically match it to Public Class Map(Of TKey, TValue) and if i new Map(Of String) the compiler will automatically match it to Public Class Map(Of TKey As IEquatable(Of TKey), TValue) (since String is an IEquatable(Of String))

Right now my solution is to give the class different names as such:

Public Class Map(Of TKey, TValue)

Public Class EqMap(Of TKey As IEquatable(Of TKey), TValue)

But I’m looking for a better solution

  • 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-22T18:57:56+00:00Added an answer on May 22, 2026 at 6:57 pm

    Sorry I don’t speak VB… but in c# (which you have in your tags) what you want is

    Map<TKey,TValue>
    {
        // implementation
    }
    

    and

    Map<Tkey,TValue>
       where TKey: IEquatable
    {
    
    }
    

    unfortunately this isn’t supported because constraints are not part of the signature you will have to provide different signatures and using different names (or possibly namespaces) is the cleanest solution IMO.

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

Sidebar

Related Questions

I need a type which can contain a position of an object in a
I need to display something such as below. Type A Type A Item 1
Is there anyway to define type parameter T as the ones that define operator
Is there a way in Java to have a map where the type parameter
I need to write a tree search method which takes a type parameter T
The Type class has a method IsAssignableFrom() that almost works. Unfortunately it only returns
I need to create a delegate type with a ref parameter at runtime. If
public struct Parameter { public Parameter(string name, string type, string parenttype) { this.Name =
In Microsoft IL, to call a method on a value type you need an
I need a way to determine the type of an HTML element in JavaScript.

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.