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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:53:10+00:00 2026-06-10T07:53:10+00:00

I want to use a dynamic object where I’d normally use Dictionary<string, string> .

  • 0

I want to use a dynamic object where I’d normally use Dictionary<string, string>.
I want to go from

dict.Add("key", "value");
string val = dict["key"];

to

 dyna.key = "value";
 string val = dyna.key

Typical ExpandoObject will return an object for dyna.key, what’s an easy way to make it return strings without casting when accessing each value?


EDIT: I’m sorry, I haven’t dug enough into my problem —

It’s not that the code I’m calling can’t use it as a string, it has THIS:

public static implicit operator SomethingSomething(string name)

That’s why it breaks

EDIT2: welp, I’m an idiot, only after recreating it from scratch did I read the full error message: has no applicable method named ‘GetMyClass’ but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.

  • 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-10T07:53:12+00:00Added an answer on June 10, 2026 at 7:53 am

    Typical ExpandoObject will return an object for dyna.key

    Erm, not exactly, it will return whatever you tell it to return:

    dynamic dyna = new ExpandoObject();
    dyna.key = "value";
    string val = dyna.key;
    

    of course you can no longer rely on compile time checking and the following code will obviously crash at runtime:

    dynamic dyna = new ExpandoObject();
    dyna.key = "value";
    int val = dyna.key;
    

    So make sure that you are using the same type as the one used to store the value.


    UPDATE:

    class Program
    {
        static void Main()
        {
            dynamic dyna = new ExpandoObject();
            dyna.key = "value";
            Test(dyna.key);
        }
    
        public static void Test(string message)
        {
            Console.WriteLine(message);
        }
    }
    

    UPDATE 2:

    I still don’t see what the problem is:

    class Program
    {
        static void Main()
        {
            dynamic d = new ExpandoObject();
            d.key = "value";
            Program p = d.key;
            Console.WriteLine(p.Name);
        }
    
        public string Name { get; set; }
    
        public static implicit operator Program(string name)
        {
            return new Program
            {
                Name = name
            };
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use dynamic object recognition (descriptive programming) to find the first button
I want to use operator overloading with dynamic object in C++ how can i
I want to use dynamic ExpandoObjects for a project I'm working on, but it
I want to use the like keyword in a dynamic parameterized query. I want
Hi I have a really complicated dynamic query that i want to use to
I set up a simple dynamic text on my stage. I want to use
I want to create a dynamic HTML5 canvas animation. This animation should use server
If I want to make a rule dynamic so i can use assert after
Basically I want to use a dynamic data website to maintain data in an
I want to use JSChart (http://www.jscharts.com/) to generate a dynamic chart. It uses a

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.