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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:45:28+00:00 2026-06-12T06:45:28+00:00

I read some article regarding expando object here but I want to achieve different

  • 0

I read some article regarding expando object here but I want to achieve different thing.
I want to add property object with dynamic property at runtime, put value on it and then retrieve later:

    private static readonly ConditionalWeakTable<object, ExpandoObject> props = new ConditionalWeakTable<object, ExpandoObject>();
    public static void AddDataExtension(this object key, dynamic value)
    {
        props.Add(key, value);
    }

    public static dynamic GetDataExtension(this object key)
    {
        ExpandoObject ex = null;
        return props.TryGetValue(key, out ex);
    }  

Usage:

'Insert data at runtime'
instance.AddDataExtension("Hello", "hi");

'Get the data at runtime'
instance.GetDataExtension("Hello")  

But I receive this error:

The best overloaded method match for 'System.Runtime.CompilerServices.ConditionalWeakTable<object,System.Dynamic.ExpandoObject>.Add(object, System.Dynamic.ExpandoObject)' has some invalid arguments  

I think I misused this property, is this possible to achieve? if yes, how? Please help.

Edit

here is the complete class:

public static class instance
{
    private static readonly ConditionalWeakTable<object, ExpandoObject> props = new ConditionalWeakTable<object, ExpandoObject>();
        public static void AddDataExtension(this object key, dynamic value)
        {
            props.Add(key, value);
        }

        public static dynamic GetDataExtension(this object key)
        {
            ExpandoObject ex = null;
            return props.TryGetValue(key, out ex);
        } 
}  

What I want to achieve is this:
I will have random varialbes, for example, “photo_01, photo_12, photo_15, name_01, name_02, age_01, age_02“
If possible I want to use the method in this way:

id = <fetch from dbase>
instance.AddDataExtension("photo_" + id, byte[]);  

And then retrieve the value:

instance.GetDataExtension("photo_" + id)  
  • 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-12T06:45:29+00:00Added an answer on June 12, 2026 at 6:45 am

    It is not possible because ExpandoObject is sealed.

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

Sidebar

Related Questions

i never use sql server ROW_NUMBER() function. so i read some article regarding ROW_NUMBER(),PARTITION
I have read from some article that say's Apple doesn't approve the application which
Some time ago I've read an article on CLR, where author showed that if
So I've read some articles about scaling Socket.IO. For various reasons I don't want
I have read some articles on POCO in the enttity framework but still don't
I read some microsoft articles.They explained that WCF uses DataContractSerializer for serialization.But the articles
I have already read some articles and searched on Google, but I failed to
I have read a ton of questions/answers on here regarding questions similar or about
i want to read a plist using cocos2d-x (c++) here is my plist: <array>
I have been doing some reading lately one article I read was from Opera.

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.