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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:48:28+00:00 2026-05-27T22:48:28+00:00

I have this c# code; case Cafe: source.trendItem = new TrendingLocation<ITrendingCafe>(); break; case Pub:

  • 0

I have this c# code;

case "Cafe":
  source.trendItem = new TrendingLocation<ITrendingCafe>();
  break;
case "Pub":
  source.trendItem = new TrendingLocation<ITrendingPub>();
  break;
etc

a trendItem is defined like this;

public class TrendingItem<T> where T : ITrendingItem
{
    public T trendItem { get; set; }
}

Then I have this;

public List<TrendingItem<ITrendingItem>> trendItems { get; set; }

Now for each item in the above trendItems i want to get the interfaces.

I tried using;

string g = fvm.trendItems[4].trendItem.GetType().GetInterfaces()[1].Name;

and

string g = typeof(TrendingLocation<>).GetInterfaces()[0].Name;

but neither of these lists the Generic interface such as ITrendingCafe, ITrendingRestaurant etc.

Is there a way I can get the name of the generic interface name?

  • 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-27T22:48:29+00:00Added an answer on May 27, 2026 at 10:48 pm

    You want to use the Type’s GetGenericArguments method.

    If I understand your structure, it will be something like:

    Type[] typeArguments = fvm.trendItems[4].trendItem.GetType().GetGenericArguments();
    
    foreach (Type tParam in typeArguments)
    {
        // Compare the type with the interface you are looking for.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have kept hearing this statement. Switch..Case is Evil for code maintenance, but it
I have some code that looks like this: someFunc(value) { switch(value){ case 1: case
This is a minimal test case of some code that I actually have. It
I have this code: CCalcArchive::CCalcArchive() : m_calcMap() { } m_calcMap is defined as this:
I have this code where $difference=0 switch ($difference) { case 0<=$difference && $difference<300: return
I have this code here: case 'resource_list': if(file_exists('content.php')){ include('../ajax/content.php'); } else { die('does not
I have this code that determines whether a word (ignoring case) is included in
I have this code to control if a EditTextPreference is null or not: case
I have this code snippet that I want to simplify: switch (typeString) { case
I have this code: while ($row = mysql_fetch_array($result)) { $pdf=new PDF(); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont('Times','',12);

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.