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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:51:17+00:00 2026-06-10T23:51:17+00:00

I have this error: Cannot implicitly convert type ‘System.Collections.Generic.List’ to ‘System.Collections.Generic.List’ For the following

  • 0

I have this error:

Cannot implicitly convert type
‘System.Collections.Generic.List’ to
‘System.Collections.Generic.List’

For the following piece of code:

When I try to add to the list:

if (information != null) // not empty
{
    foreach (CharacterInformation info in information)
    {
        chButtons.Add(new GuiSelectCharacterButton(
            selectGui,
            new Rectangle(100, 100, 450, 100)
        ));
        chButtons[chButtons.Count - 1].ImageTexture = GUISprites.Instance().GetTexture(UITexture.RainbowDash);
        chButtons[chButtons.Count - 1].Texture = GUISprites.Instance().GetTexture(UITexture.CommonButtonNotPressed);
        chButtons[chButtons.Count - 1].PressedTexture = GUISprites.Instance().GetTexture(UITexture.CommonButtonPressed);
        chButtons[chButtons.Count - 1].ImageTextureWidth = 90;
        chButtons[chButtons.Count - 1].ImageTextureHeight = 90;
        chButtons[chButtons.Count - 1].ButtonPressed += LoginCharacterHandler;
        chButtons[chButtons.Count - 1].Font = GameFonts.Instance().GetSpriteFont(FontType.UI);
        chButtons[chButtons.Count - 1].Information = information[chButtons.Count - 1];
    }
}
// error at this line
buttoncontainer.ButtonList = chButtons;

Class declaration:

public class GuiSelectCharacterButton : GUIImageButton, IGameUserInterfaceImageButton
{
    public GuiSelectCharacterButton(GUI parent, Rectangle area)
        : base(parent, area)
    {

    }
}

Interface:

public interface IGameUserInterfaceImageButton : IGameUserInterfaceComponent
{
    bool InsideContainer { get; set; }
    Rectangle InsideContainerArea { get; set; }
}

List of IGameUserInterfaceImageButton:

private List<IGameUserInterfaceImageButton> buttonList;

public List<IGameUserInterfaceImageButton> ButtonList
{
    get
    {
        return buttonList;
    }
    set
    {
        buttonList = value;
        scrollbarThumbTotalHeight = marginButtons;
        scrollbarThumbY = 0;
        int yhelper = 0;
        foreach (IGameUserInterfaceImageButton button in buttonList)
        {
            yhelper += marginButtons;
            button.InsideContainer = true;
            button.InsideContainerArea = new Rectangle(
                marginXbutton,
                yhelper,
                button.Area.Width,
                button.Area.Height
            );
            yhelper += marginButtons + button.Area.Height;
            scrollbarThumbTotalHeight += button.Area.Height + marginButtons * 2;
        }
        scrollbarThumbDrawHeight = 0;
        if (scrollbarThumbTotalHeight > Area.Height)
        {
            scrollbarThumbDrawHeight = (int)Math.Pow(AreaScrollbar.Height, 2) / scrollbarThumbTotalHeight;
        }
    }
}

I don’t know where my mistake is. The base class (GUIImageButton) implements everything of said interface. I did this on other parts of my program but for any weird reason it doesn’t work here.

  • 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-10T23:51:19+00:00Added an answer on June 10, 2026 at 11:51 pm

    You can’t cast directly from List<A> to List<IA> event when A inherits from IA.

    What you can do is make chButtons also of type IGameUserInterfaceImageButton. Then cast each item to the interface, as you add them:

    var chButtons = new List<IGameUserInterfaceImageButton>();
    chButtons.Add(
        (IGameUserInterfaceImageButton)new GuiSelectCharacterButton(
            // etc ...
        )
    );
    // this is now valid
    buttoncontainer.ButtonList = chButtons
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first LINQ query and I have following error Cannot implicitly convert
I get the error Cannot implicitly convert type 'string' to 'System.Web.HtmlString' when I attempt
I have no idea why I'm getting this following error: Control cannot fall through
I have three classes in my C# program. Get the following error: Cannot implicitly
I get this error message pageContext cannot be resolved but I have no variable
Please help! I have been grappling with this error for days and I cannot
I have this error message could not load assembly 'system.data.entity, version 4.2.0.0, culture=neutral,publickeytoken=b77a5c561934e089' or
Edit: I have tried the Take/Skip method but I get the following error: Cannot
I have this error when trying to generate the meta model with JOOQ: org.jooq.exception.DataAccessException:
I Have this error message : Possible unitended reference comparison; to get a value

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.