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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:44:19+00:00 2026-06-05T01:44:19+00:00

I have a dynamic object that looks as follows: this.ChartDetails.Chart ‘Chart’ is dynamic. I

  • 0

I have a dynamic object that looks as follows:

this.ChartDetails.Chart

‘Chart’ is dynamic. I want to see if a dynamic property exists on Chart named LeftYAxis. What is the best way to do this on dynamic objects?

I don’t think this is a duplicate of How to detect if a property exists on an ExpandoObject? because it doesn’t discuss the best method to do this for dynamic objects.

  • 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-05T01:44:22+00:00Added an answer on June 5, 2026 at 1:44 am
    bool isDefined = false;
    object axis = null;
    try
    {
        axis = this.ChartDetails.Chart.LeftYAxis;
        isDefined = true;
    }
    catch(RuntimeBinderException)
    { }
    

    This is what happens at runtime in the first place. (When you access a property the ‘dynamic’ piece of things only happens when a first-chance exception gets handled by the object’s override of DynamicObject‘s TryGetMember and TrySetMember

    Some objects (like ExpandoObject) are actually dictionaries under the hood and you can check them directly as follows:

    bool isDefined = ((IDictionary<string, object>)this.ChartDetails.Chart)
        .ContainsKey("LeftYAxis");
    

    Basically: without knowing what actual type ChartDetails.Chart is (if it’s an ExpandoObject a plain ol’ subclass of object or a subclass of DynamicObject) there’s no way besides the try/catch above. If you wrote the code for ChartDetails and Chart or have access to the source code you can determine what methods exist for the object and use those to check.

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

Sidebar

Related Questions

I have dynamic json result and i want to create an object for that
Let's say my domain looks like this: I have an object, Vehicle, that has
I have an anonymous type object that I receive as a dynamic from a
I have a WebMethod that looks like this which is used to populate a
I currently have a Database Command object in my Crystal Report that looks something
I have JSON string that has nested objects with dynamic names that vary each
Say i have a object in dynamic memory (new) and inside one of its
I have dynamic content in a div called txtresults like this: <div id=txtresults></div> This
I have some divs that have dynamic heights controlled by a 'click' function as
I have some divs that have dynamic heights controlled by a 'click' function as

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.