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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:20:35+00:00 2026-05-15T12:20:35+00:00

I have several classes that implement the same interface. interface IBidManager<E> where E :

  • 0

I have several classes that implement the same interface.

interface IBidManager<E> where E : IEntity

public class BidManager : IBidManager<EntityObject1>
public class BidManager2 : IBidManager<EntityObject2>
public class BidManager3 : IBidManager<EntityObject3>

In my business manager class I have:

public class BusinessManager : ManagerBase
{
    private IBidManager<IEntity> _bidLogicManager;
    ...

In the BusinessManager is a function I call to change the _bidLogicManager (MyType is an enum)

public void SetLogic(MyType auctionType)
{
    switch (MyType)
    {
        case AuctionType.Classic:
            _bidLogicManager = (IBidManager<IEntity>)new BidManager();
            break;
  ...

IEntity is a blank interface that I use with my POCO classes generated by a t4 and the Entity framework.

I could have swore this was working, but I tried it again and its throwing error sayng:

Unable to cast object of type 'BLL.MyManagers.BidManager' to type 'BLL.BidManagers.IBidManager`1[Entities.IEntity]'.

When I remove (IBidManager) visual studio tells me that an explicit conversion exists… but what is it?

I do not want to define the type when creating the BusinessManager class like so:

public class BusinessManager<E> : ManagerBase where E : class, IEntity
{
      IBidManager<E> _bidLogicManager;

Also, I cannot create a function in the Business manager that takes a IBidManager<E> argument since this is a n-layer asp.net app and I do not want the UI layer knowing anything about the IBidManager

  • 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-15T12:20:35+00:00Added an answer on May 15, 2026 at 12:20 pm

    If you can use .Net 4.0, you can solve your cast problem via covariance.

    interface IBidManager<out E> where E : IEntity.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several templated objects that all implement the same interface: I.E. MyObject<datatype1> obj1;
I have a main class and several inherited classes that implement a method with
I have commands classes that implement ICommand { Execute } interface. Several commands have
I have an the following scenario: // several classes that implement different interfaces class
If I have interface IFoo, and have several classes that implement it, what is
I have a class that has several member classes as attributes. The constructor of
Sometimes we have several classes that have some methods with the same signature, but
I have a Role and several classes that mix-in the role. The Role class
I have an interface that is used by several classes and the interface implementation
This is for a web project so i have several classes that inherit from

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.