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

  • Home
  • SEARCH
  • 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 7865757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:11:00+00:00 2026-06-03T00:11:00+00:00

For an application I’m working on I’m trying to display a template that will

  • 0

For an application I’m working on I’m trying to display a template that will show what the parameters for a (runtime-determined) method look like. The test case I’m working on should show “PERSON = (FIRST = first; LAST = last);”, where the parameter named Person has type Name, and Name has two properties, First and Last. The following code instead shows “PERSON = ();”.

GetNestedTypes is not returning anything, any ideas why?

public static string GetParameterTemplate(MethodInfo method)
{
    StringBuilder output = new StringBuilder();
    foreach (ParameterInfo pi in method.GetParameters())
    {
        output.Append(parameterTemplateHelper(pi.Name, pi.ParameterType));
    }
    return output.ToString();
}

private static string parameterTemplateHelper(string pName, Type pType)
{
    string key = pName.ToUpper();
    string value = "";

    if (pType.IsPrimitive)
    {
        // it's a primitive
        value = pName.ToLower();
    }
    else if (pType.IsArray)
    {
        if (pType.GetElementType().IsPrimitive)
        {
            // array of primitives
            value = String.Format("{0}1, {0}2;", pName.ToLower());
        }
        else
        {
            // array of objects
            StringBuilder sb = new StringBuilder();
            foreach (Type t in pType.GetElementType().GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic))
            {
                sb.Append(parameterTemplateHelper(t.Name, t));
            }
            value = String.Format("({0}), ({0});", sb);
        }
    }
    else
    {
        // object
        StringBuilder sb = new StringBuilder();
        Type[] junk = pType.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic);
        foreach (Type t in pType.GetNestedTypes())
        {
            sb.Append(parameterTemplateHelper(t.Name, t));
        }
        value = String.Format("({0});", sb.ToString());
    }

    string output = key + " = " + value.ToString();
    return output;
}
  • 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-06-03T00:11:01+00:00Added an answer on June 3, 2026 at 12:11 am

    Your code is looking for nested types – that is, other types declared within Person. That’s not at all the same as looking for properties within Person.

    Here’s a class with nested types:

    public class Name
    {
        public class Nested1 {}
        public class Nested2 {}
    }
    

    Here’s a class with properties:

    public class Name
    {
        public string Name { get; set; }
        public string Name { get; set; }
    }
    

    My guess is that your situation is much more like the second one than the first… so use Type.GetProperties instead of Type.GetNestedTypes.

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

Sidebar

Related Questions

Application : I am working on one mid-large size application which will be used
Application : HTA (therefore IE) This is an application that uses SendKeys to populate
my application use 10 threads that to read a lot of html file.similar the
application = webapp.WSGIApplication( [(r'/main/profile/([a-f0-9]{40})', ProfileHandler)], debug=True) The regex in the above parameter will not
My application that is not on Play Store verify on the web If there
Application is a C# .Net 3.5 WCF Service. I'd like during the build process
APPLICATION DESCRIPTION : I am a new iPhone developer. I am working on an
Application is to display device distance to GPS coordinate on screen of mobile device
Application use NHibernate. I Have object A that contains set of objects B. I
My application has to detect that the device connected to the Wi-Fi network is

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.