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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:05:31+00:00 2026-05-24T09:05:31+00:00

Edit: Changed the wrong term boxing to casting. I have the following problem: If

  • 0

Edit: Changed the wrong term boxing to casting.

I have the following problem:

If I create a new Delegate of type Action or Func it will be casted to a type of Delegate.

var @delegate = Delegate.CreateDelegate(type, @object, methodInfo);

But I need for a generic class the right casted object.

Consider following example:

class Example<T> {
    Type GenericType() {
        return typeof(T);
    }
}

static Example<T> Create<T>(T @delegate) {
    return new Example<T>();
}

Example.Create(@delegate).GenericType();

This will return Delegate as type, since this was the type of the casted object (@delegate).

One solution could be to cast the delegate like so:

if(@delegate is Action)
    Example.Create((Action)@delegate).GenericType();

But since Delegate.CreateDelegate could also create Action or Func delegates, it is impossible to check all variations.

I can’t change the generic class, so i must cast the delegate.

I hope i was able to explain my problem. I am not a native English speaker…

Edit: The Problem is that typeof(T) not return the “real” type of the object. But i’m afraid there is no solution.

  • 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-24T09:05:32+00:00Added an answer on May 24, 2026 at 9:05 am

    To answer my own question: It is not possible. 🙁

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

Sidebar

Related Questions

i have the following jquery code: $(document).ready(function() { $('.restrictiveOptions input[type!=checkbox], .restrictiveOptions select').change(function() { //
EDIT: I have changed my program according to suggestions people have made but I
I have a problem with a TryUpdateModel in MVC3 When the Edit (post) is
Is there a way to change the default pages used to edit/create/view a Sharepoint
And why don't they change it? Edit: The reason ask is because I'm new
I've got a file with the following changes: # Manual hunk edit mode --
EDIT: changed the whole question sorry, im trying to deal with the mysql DATETIME
EDIT: onload() method changed to afterLoad(): Otherwise objects might not be passed properly to
[edit]: Figured out where it goes wrong. It has something to do with my
Edit: My original title has been sort of changed. I suspect the current title

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.