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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:17:39+00:00 2026-05-11T15:17:39+00:00

We have a requirement where we need to generate delegate types on the fly.

  • 0

We have a requirement where we need to generate delegate types on the fly. We need to generate delegates given the input parameters and the output. Both input and output would be simple types.

eg, we need to generate

int Del(int, int, int, string) 

and

int Del2(int, int, string, int) 

Any pointers on how to get started on this would be very helpful.

We need to parse formulate which are represented as xml.

For example, we represent (a + b) as

<ADD>     <param type='decimal'>A</parameter>     <param type='decimal'>B</parameter> </ADD> 

We now want this to be exposed as Func<decimal, decimal, decimal>. We of course want to allow nested nodes in the xml, e.g:

(a + b) + (a - b  * (c - d))) 

We want to do this using expression trees and Expression.Compile.

Suggestions on the feasibility of this approach are welcome.

  • 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. 2026-05-11T15:17:40+00:00Added an answer on May 11, 2026 at 3:17 pm

    The simplest way would be to use the existing Func family of delegates.

    Use typeof(Func<,,,,>).MakeGenericType(...). For example, for your int Del2(int, int, string, int) type:

    using System;  class Test {     static void Main()     {         Type func = typeof(Func<,,,,>);         Type generic = func.MakeGenericType             (typeof(int), typeof(int), typeof(string),              typeof(int), typeof(int));         Console.WriteLine(generic);     } } 

    If you really, really need to create a genuinely new type, perhaps you could give some more context to help us help you better.

    EDIT: As Olsin says, the Func types are part of .NET 3.5 – but if you want to use them in .NET 2.0, you just have to declare them yourself, like this:

    public delegate TResult Func<TResult>(); public delegate TResult Func<T, TResult>(T arg); public delegate TResult Func<T1, T2, TResult>(T1 arg1, T2 arg2); public delegate TResult Func<T1, T2, T3, TResult>     (T1 arg1, T2 arg2, T3 arg3); public delegate TResult Func<T1, T2, T3, T4, TResult>     (T1 arg1, T2 arg2, T3 arg3, T4 arg4); 

    If 4 arguments isn’t enough for you, you can add more of course.

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

Sidebar

Ask A Question

Stats

  • Questions 100k
  • Answers 100k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer DataTables are definitely much heavier than Lists, both in memory… May 11, 2026 at 8:00 pm
  • Editorial Team
    Editorial Team added an answer A decorator seems a better option to me. I am… May 11, 2026 at 7:59 pm
  • Editorial Team
    Editorial Team added an answer The current version has improved support for tab order, so… May 11, 2026 at 7:59 pm

Related Questions

I believe several of us have already worked on a project where not only
We're not doing real web development. We get our HTMLs from our designers, and
We have a deployment system at my office where we can automatically deploy a
An upcoming project of mine is considering a design that involves (what I'm calling)
We have a requirement to have our ASP.NET MVC websites be automatically closed down

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.