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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:48:14+00:00 2026-05-30T02:48:14+00:00

We have a legacy application that has a class like this : public class

  • 0

We have a legacy application that has a class like this :

public class Person
{
private PersonType _type;

public PersonType GetPersonType()
{
return _type;
}
}

PersonType is a base class of several person types (User,Customer and …)

so every time we want to get the type to do something with it we should cast it like this :

var userType=(User)Person.GetPersonType();

Then I thought maybe we can have a generic overload like this :

var userType=Person.GetPersonType<User>();

So I added the overloaded method to class. Later I found out that there’s another code that uses reflection to get the first method :

var methodInfo=person.GetType().GetMethod("GetPersonType");

but since I have added this overload we are getting an ambiguous method exception.I tried to find a way to somehow distinguish the exact overload that I was looking for with no success.
So the question is how we can o get the non-generic overload info ?
(As I said it’s a legacy app built using framework 2 and we can’t use Linq and\or Extensions.)

  • 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-30T02:48:16+00:00Added an answer on May 30, 2026 at 2:48 am

    You can tell which method is the first non-generic one like this:

    MethodInfo[] methods = person.GetType().GetMethods();
    foreach (MethodInfo mi in methods)
        if (mi.Name == "GetPersonType" && !mi.IsGenericMethodDefinition)
            return mi;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a legacy VB6 application that has the following structure defined: Public Type
I currently have a database that gets updated from a legacy application. I'd like
I have a Rails application that has to co-exist with a very old legacy
We have an legacy application (mixture of classic ASP and ASP.net) that has a
I have an application which has legacy Struts actions extending org.apache.struts.StrutsActions. I would like
I have an application that has numerous activities. I set this in the manifest:
I have a legacy system that I'd like to extend with an application written
I have recently started working on a legacy application that has most of its
How would you maintain the legacy applications that: Has no unit tests have big
I have a legacy application that I inherited that passes a lot of XML

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.