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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:03:50+00:00 2026-06-04T06:03:50+00:00

this is somewhat the same question as I’ve asked some time ago: How to

  • 0

this is somewhat the same question as I’ve asked some time ago:
How to let a method accept two types of data as argument?

Yet the current situation differs.. a lot.

Take this:

public FormResourceSelector(Dictionary<string, Effect> resourceList, string type)

Alright, nothing wrong with it.
Now I try to run this:

FormResourceSelector frs = new FormResourceSelector(AreaEffect.EFFECTS, "Area effect");
FormResourceSelector frs2 = new FormResourceSelector(DistanceEffect.EFFECTS, "Distance effect");

Both AreaEffect and DistanceEffect (custom classes) derive from Effect.

public class AreaEffect : Effect
{
    public static Dictionary<string, AreaEffect> EFFECTS = new Dictionary<string, AreaEffect>();
    ...
}

For some reason I get the following error while making the new FormResourceSelector instance:

Argument 1: cannot convert from 'System.Collections.Generic.Dictionary<string,SCreator.AreaEffect>' to 'System.Collections.Generic.Dictionary<string,SCreator.Effect>'  

at:

new FormResourceSelector(AreaEffect.EFFECTS, "Area effect");

I suspect the dictonary being a harass, but I don’t really know how to fix this.

EDIT: Easiest would be to allow input of both Dictionary and Dictionary as resourceList in the first code snippet I’ve given.

  • 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-04T06:03:50+00:00Added an answer on June 4, 2026 at 6:03 am

    Why not make your class generic?

    public class FormResourceSelector<T>
        where T : Effect
    {
        public FormResourceSelector(Dictionary<string, T> resourceList, string type)
        {
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is somewhat similar to How to combine two branches from two different
This is a somewhat low-level question. In x86 assembly there are two SSE instructions:
Somewhat of an academic question, but I ran into this while writing some unit
this is somewhat of an odd question. I wrote a C function. Its 'like'
This is somewhat related to the question posed in this question but I'm trying
I know this sounds somewhat counterintuitive, but let me explain what I am trying
If anyone read my last question, this is somewhat of a continuation of it.
Rails 3.1, ActiveAdmin 0.3.4. My question is somewhat similar to this one but different
Asked the same question here but got no answer, so I'm trying here instead
This is the same question as this but I'm looking for a classic ASP

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.