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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:53:51+00:00 2026-06-07T23:53:51+00:00

I have two libraries in a 3-tier project – call them BO and DAL.

  • 0

I have two libraries in a 3-tier project – call them BO and DAL. Almost every class in DAL implements a Save Method:

Public Function Save(ByVal someObject As BO.SomeType) As Boolean

As I have to add the missing Save methods, I though it was a good idea to create an interface which implements a ‘MustInherit Save’ function. So if I type:

MustOverride Function Save(ByVal someObject As BO.SomeType) As Boolean

That should do the trick; but the type of the parameter is always different. For example, in class DAL.TypeA:

Public Function Save(ByVal someObject As BO.SomeTypeA) As Boolean

And in class DAL.TypeB:

Public Function Save(ByVal someObject As BO.SomeTypeB) As Boolean

Is there a way to handle different type of parameters in an interface? Some kind of generic? Is this even possible?

  • 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-06-07T23:53:54+00:00Added an answer on June 7, 2026 at 11:53 pm

    Perfect use case for generics.

    Using a generic interface:

    Interface:

    Interface ISave(Of T)
    
        Function Save(someObject As T) As Boolean
    
    End Interface
    

    Implementation:

    Class BoClass
        Implements ISave(Of BoClass)
    
        Public Function Save(someObject As BoClass) As Boolean Implements ISave(Of BoClass).Save
        End Function
    
    End Class
    
    Class DalClass
        Implements ISave(Of DalClass)
    
        Public Function Save(someObject As DalClass) As Boolean Implements ISave(Of DalClass).Save
        End Function
    
    End Class
    

    Or, using a generic base class instead of an interface

    Base class

    MustInherit Class BaseClass(Of T)
    
        MustOverride Function Save(someObject As T) As Boolean
    
    End Class
    

    Implementation

    Class BoClass
        Inherits BaseClass(Of BoClass)
    
        Public Overrides Function Save(someObject As BoClass) As Boolean
        End Function
    
    End Class
    
    Class DalClass
        Inherits BaseClass(Of DalClass)
    
        Public Overrides Function Save(someObject As DalClass) As Boolean
        End Function
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have two projects that are both class libraries. Project 1 is a VS
Need to add two same name .csproj class libraries in my solution.Have two project
I have a project that uses two independent Android libraries. Each of them contains
I have two different java projects (I'll call them project 1 and Project 2
I have two libraries and a single application assembly project layout and I'm wondering
I have two class libraries MyLibrary.dll and MyLibraryEditor.dll for a Unity runtime and editor
I have a project that uses two third party libraries, both of which make
I have two large framework libraries, whose header files are included in my project.
In my project I have two libraries that would currently result in a circular
Let's say that I have two libraries (A and B), and each has one

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.