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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:30:45+00:00 2026-05-15T00:30:45+00:00

I was looking at the answer of this question regarding multiple generic types in

  • 0

I was looking at the answer of this question regarding multiple generic types in one container and I can’t really get it to work: the properties of the Metadata class are not visible, since the abstract class doesn’t have them. Here is a slightly modified version of the code in the original question:

public abstract class Metadata
{
}

public class Metadata<T> : Metadata
{
    // Per Ben Voigt's comments, here are the rest of the properties:
    public NUM_PARAMS NumParams { get; set; }
    public FUNCTION_NAME Name { get; set; }
    public List<Type> ParamTypes { get; set; }
    public Type ReturnType { get; set; }
    //...C
    public T Function { get; set; }
    public Metadata(T function)
    {
        Function = function;
    }
}

List<Metadata> metadataObjects;
metadataObjects.Add(new Metadata<Func<double,double>>(SomeFunction));
metadataObjects.Add(new Metadata<Func<int,double>>(SomeOtherFunction));
metadataObjects.Add(new Metadata<Func<double,int>>(AnotherFunction));

foreach( Metadata md in metadataObjects)
{
      var tmp = md.Function; // <-- Error: does not contain a definition for Function
}

The exact error is:

error CS1061: ‘Metadata’ does not
contain a definition for ‘Function’ and no
extension method ‘Function’ accepting a
first argument of type ‘Metadata’
could be found (are you missing a
using directive or an assembly
reference?)

I believe it’s because the abstract class does not define the property Function, thus the whole effort is completely useless. Is there a way that we can get the properties?

Update

The basic idea is that I have a genetic program that uses the Metadata of functions (or MetaFunctions) in order to construct expression trees with those functions. The meta data allows me to correctly match the return from one function with the input parameters of another function… it basically turns my functions into legos and the computer can combine them in various ways. The functions are all within the same “domain”, so I won’t have any problem with randomly mixing and matching them.

I’m storing the Metadata, or MetaFunctions, into a couple of dictionaries:

  • one has the name of the function as the key.
  • the other has the number of parameters as the key.

In any case, I just tried to stick as close to the original question as possible… the fundamental problem is the same regardless if I use a List or a Dictionary. I’m also stuck with .NET 3.5 and I won’t be able to update to .NET 4.0 for a while.

  • 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-15T00:30:46+00:00Added an answer on May 15, 2026 at 12:30 am

    What would you do with md.Function if you could read it? You can’t call it, because you don’t know the parameter types. With C# 4.0, you could use dynamic, e.g. foreach (dynamic md in metadataObjects) and then you don’t need the Metadata abstract base class. If you just want to access members of Delegate, you could change the abstract base class to an interface which has a Delegate Metadata { get; } property and explicitly implement it in Metadata<T>, then you could access e.g. the function’s name.

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

Sidebar

Related Questions

I've been looking for an existing answer to this question, but haven't found one.
I'm looking for an answer to a question similar to this one: protect users'
This question seems to get asked a lot, but I can't find an answer
All day I was looking an answer on this question: How to log in
While looking up the answer to this question: Why is an out parameter not
I have been looking at the answer to this question: Pulling details from response
I've been looking for some considerable time for an answer to my question regarding
I've seen many questions regarding this topic, yet I cannot find one satisfactory answer.
I have been looking all over the Internet for an answer to this question
I'm looking for an answer to this problem: I'm running through a loop testing

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.