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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:59:38+00:00 2026-06-15T18:59:38+00:00

if you do need to get a required information, being a field or propertie

  • 0

if you do need to get a required information, being a field or properties values / names,

HOW could you do it not by using System.Reflection ?

public class anyClass
{
    public const string UserID  = "usrID",
                        UserName = "usrName";
}

so it happens, as i really wanted to know if it’s possible to avoid using reflection,

i have conducted a little research and ..seems to me that, the correct Term for my mission is

Type introspection ( a dediced tag does not exitst here in SO)

Introspection should not be confused with reflection,

which goes a step further and is the ability for a program to manipulate the values,

meta-data, properties and/or functions of an object at runtime.

by using system reflection i could access Fields– values, as in this example code :

    var ac = new anyClass();
    public List<string> anyClassFieldsValuesList()
    {
      // sorry this was the one for the class above
      return typeof(anyClass).GetFields()
                     .Select(f =>f.GetValue(ac).ToString()).ToList<string>();


     // this would do for nested class
     // return typeof(anyClass).GetNestedTypes()
                    .First(t => String.Compare(t.Name, "anyNested", true) == 0)
                    .GetFields()
                    .Select(f => f.GetValue(ac).ToString())
                    .ToList<string>();
    }

Does .net offers us a usage of tools or other approach to get that information in a less expensive way ?

  • 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-15T18:59:39+00:00Added an answer on June 15, 2026 at 6:59 pm

    The emphasis on expensive suggests that performance is your main concern. If that is the case, there are libraries out there that exist to remove the overhead of reflection, by caching of metadata and meta-programming. But they are often very specific in their intent.

    For example, FastMember will help with knowing what members exist, and allowing access to their values (without the usual associated overhead of reflection), but: it doesn’t help with the GetNestedTypes bit.

    For example, to get all values from a given object, based on what ac actually is:

    // requires FastMember
    var accessor = TypeAccessor.Create(ac.GetType());
    var values = accessor.GetMembers()
            .Select(member => accessor[ac, member.Name]).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to get an div with overflow:hidden; not to wrap its children. I need
I need to get information on loaded data percentage when UIWebView loads page. I
I'm using django-cms with apphooks to display book detail information. I need the page
System Specs: Infopath 2007 with c# code-behind Webservices Active Directory I need to get
I need get the id of an images which is place inside a datatemplate..
Just need get some vals located in application.ini(main ini) in the Controller plugin I
I need get all items these have no categories int? categoryId = null; var
I have linq request. I need get item.Title in select. how do this? var
I have two tables with a weak relation. I need get a text value
Need to get the 10 word before and 10 words after for the given

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.