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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:46:45+00:00 2026-05-13T07:46:45+00:00

Everywhere I read about the new DLR in .net 4, they say that a

  • 0

Everywhere I read about the new DLR in .net 4, they say that a good use for it is reflection, and the code snippet always shown is something like

dynamic d = GetSomeObject();
d.DoSomething();
d.SomeMember = 1;

What does GetSomeObject() look like? I can’t find anywhere that explains that.

I understand that it can be anything, but in the context of reflection what is it? Is it the assembly? an instance of a type?

  • 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-13T07:46:45+00:00Added an answer on May 13, 2026 at 7:46 am

    The return type of GetSomeObject() will be an instance of some type. For example, here’s what it might look like:

    public Customer GetSomeObject() {
        return new Customer("John", "Doe", 12345);
    }
    

    And then the code would say:

    dynamic customer = GetSomeObject();
    string s = customer.FirstName;
    // now the "s" variable would have "John" in it
    

    The GetSomeObject() can return anything. It might return a Customer object or a Product. And it doesn’t matter! The idea is that when the variable is declared as being dynamic that when you call a method or a property, as you have shown, the compiler will generate code that uses Reflection to try and call the method or property. If they exist then the calls will succeed. If not then you’ll get an error at runtime.

    In the general case this example is just simplifying the usage of Reflection by having the compiler generate the code for you.

    Having said that, if the Customer or Product object implement IDynamicObject themselves then they can do far more advanced stuff.

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

Sidebar

Related Questions

I am new to db programming. I read everywhere that I can use trasactions
I have read so many times, here and everywhere on the net, that mutexes
Everywhere I read about Mercurial and Git they generally throw in a line or
Everywhere I read about converting time to a user's timezone says that the best
Im getting really lost on how to use HttpContext.User. I read everywhere that its
I read everywhere that rewriting history of commits that have been published is bad
Althoug I read everywhere that the method signature has a BOOL for finished, I
It seems everywhere I read that either a library boasts if not needing RTTI
I'm using PHP PDO for my queries, everywhere, but I read that in very
Everywhere I see, can't find any info about it. I need that people who

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.