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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:11:47+00:00 2026-05-14T01:11:47+00:00

I have a function that accepts a generic parameter T that is of type

  • 0

I have a function that accepts a generic parameter T that is of type class like so :

public  Func<T, bool> MyMethod<T>(string paramName, object value) where T : class

But when calling the function I do not have direct access to the class that needs to be the parameter.

MyMethod<foo>("foo1", "foo2")

Is there a way I can get the class foo via other means like reflection so I can use the function?

UPDATE:

This method in particular performs a Lambda expression through LINQ and checks if the parameter value is equal to the value I passed… So T value will not make sense i.e. that’s why I need an object type. Also My real problem is that I can’t do something like;

MyMethod<fooInstance>("foo1","foo2")

and I need to get a reference of the Type rather than class. This because the class name is encrypted so i need to get the Type reflection using the Activator class and assign the object returned to the generic call of MyMethod function

example:

object o = Activator.CreateInstance(Type.GetType(Assembly.GetExecutingAssembly().GetName().Name + ".Foo"));
    MyMethod<o.getType()>("foo1","foo2");
  • 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-14T01:11:47+00:00Added an answer on May 14, 2026 at 1:11 am

    You can use

    Type type = typeof(T);
    

    to get the type passed in as T.

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

Sidebar

Related Questions

I have a function that accepts a class (not an instance) and, depending on
I have a function that accepts wildcard keyword parameters: def func(**kargs): doA doB How
I have a function that accepts a variable number of parameters: foo (Class... types);
I have a function that accepts a string and generates an email attachment based
Please suppose I have a function that accepts a pointer as a parameter. This
I have a function that accepts a string, that is: void log_out(char *); In
In .NET, the Generics Lists have a sort function that accepts IComparer or Comparison
I have a javascript function that accepts a number and performs a mathematical operation
I have a function foo that accepts a Boolean function def foo( f:(_)=>Boolean )
Does Actionscript have a built-in function that accepts a number and can return a

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.