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

  • Home
  • SEARCH
  • 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 7896099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:48:22+00:00 2026-06-03T07:48:22+00:00

I tried to insert an object into a generic BindingList. But if I try

  • 0

I tried to insert an object into a generic BindingList.
But if I try to add a specific object the compiler says:
“Argument type … is not assignable to parameter type”

private void JoinLeaveItem<T>(BindingList<T> collection)
    {

        if (collection.GetType().GetGenericArguments()[0] == typeof(UserInformation))
        {
            var tmp = new UserInformation();
            collection.Add(tmp);
        }
    }

Please help me

  • 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-03T07:48:24+00:00Added an answer on June 3, 2026 at 7:48 am

    You cannot have objects of two different types that does not have a common anscestor in a strongly typed list. That is: In your case you will need to different collections unless your two (or more) classes have a common base class.

    Try creating overloads instead, like this

    private void JoinLeaveItem(BindingList<UserInformation> collection)
    {
        collection.Add(new UserInformation());
    }
    
    private void JoinLeaveItem(BindingList<GroupInformation> collection)
    {
        collection.Add(new GroupInformation());
    }
    

    Use it like this

    JoinLeaveItem(userInformationCollection)
    JoinLeaveItem(groupInformationCollection)
    

    Note: I’ve inlined the tmp variable.

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

Sidebar

Related Questions

i tried something like this, it insert into the database even thought nric is
I am using the SqlBulkCopy object to insert a couple million generated rows into
I have tried to restrict Following EventHandler In specific Columns of Datagridview but fail
This code works really well for an initial insert into a table. But now
I created MVC ASP.Net Web application and tried insert Thai language data to SQL
I tried to insert a set of rows as soon as a table is
I'm going crazy today. I just tried to insert a new record and it
How to insert html code inside an array in PHP? I tried searching on
I have a method which does a simple mysql insert, when I tried to
Tried a bunch of things but I can't get it to work consistently amid

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.