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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:42:56+00:00 2026-05-18T21:42:56+00:00

I have a particular need which I cannot seem to figure out. I’ve done

  • 0

I have a particular need which I cannot seem to figure out. I’ve done some research into this, but cannot find a feasible solution.

I have a base class:

public abstract class BaseProvider<T> {}

this class in turn is inherited by two different provider classes:

public sealed class MonkeyProvider<T> 
       : BaseProvider<MonkeyProvider<T>> 
         where T 
       : IAnimalProvider

Within in the interface IAnimalProvider I expose a single property that all implementations must derive off. Now, MonkeyProvider and maybe DonkeyProvider or something similar needs to know what the assigned value for the property the root instance is:

public class JoburgZoo
       : IAnimalProvider
{
     #region IAnimalProvider members
     public string Id{ get; set; }
     #endregion
}

// somewhere in a console application
public static void Main(string[] args)
{
     JoburgZoo zoo = new JoburgZoo();
     zoo.Id = "Mammals";

     **// edit: an instance of the provider will be created**
     MonkeyProvider<JoburgZoo> mp = new MonkeyProvider<JoburgZoo>();
     mp.CheckMonkeys(zoo); // where CheckMonkeys(JoburgZoo) is a method in the provider
}

Now, here is my actual question:

I have the need to expose an internal property through BaseProvider which every instance that implement it, has access to. This property needs to return the value of “Id” at any given point, but I cannot seem to be able get the value through reflection (which I know is the solution to this).

From my various fruitless efforts:

Type type = typeof(T); // this returns BaseProvider<MonkeyProvider<T>>
var generic = type.GetGenericTypeDefinition(); // brings back BaseProvider<T>

I can’t create a new instance of T as it will clear all values currently assigned to the object. I can’t iterate the property info collection, as that will only return the properties of BaseProvider.

Thanks for any help on this.
Eric

// Edit.
Added an additional call in the console main code above. the instance of MonkeyProvider<T> templates JoburgZoo, so in ProviderBase<T> it will look something like:

ProviderBase<MonkeyProvider<JoburgZoo>>

I want to know what the properties of JoburgZoo is, from within the BaseProvider<T> without the need to identify the object withing MonkeyProvider<T>.

Hope this makes sense.

  • 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-18T21:42:56+00:00Added an answer on May 18, 2026 at 9:42 pm

    With following class definition,

        class BaseProvider<T>
        {
            //...
        }
    

    following code returns System.Int32 :

            Type type = typeof(BaseProvider<Int32>);
            foreach (var arg in type.GetGenericArguments())
            {
                MessageBox.Show(arg.FullName);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a input tag which is non editable, but some times i need
In our application, we have some forms which need to show some data specifically
I have a great framework however I cannot figure out how to create requests.
I need to have a routine/function/stored proc/whatever to archive particular accounts from our 'active'
Greetings, I have a particular object which can be constructed from a file, as
Using jQuery, how would you find elements which have a particular style (eg: float:
My particular problem: I have a string which specifies an aribitrary type in a
I need to identify items of interest nearby to a particular latitude/longitude. I have
I've searched google and cannot find any answers to the particular problem. I have
I have a particular PHP page that, for various reasons, needs to save ~200

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.