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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:21:03+00:00 2026-06-09T23:21:03+00:00

Possible Duplicate: Dictionary With Value “Variable” I have some highly coupled code that I

  • 0

Possible Duplicate:
Dictionary With Value “Variable”

I have some highly coupled code that I am trying to decouple. If I could make a Dictionary like this:

Dictionary<string, var> dict = new Dictionary<string, var>

a lot of coupling could be fixed. One poster in another thread seems to have found a solution using a Variable class but he/she didn’t post any details of this class and I can’t think of how to do it.

EDIT:

Basically, instead of:

string transit = <string value>;

I would like to be able to write:

string dict["Transit"] = <string value>;

Where I have already done:

Dictionary<string, var> dict = new Dictionary<string, var>()
{
    {"Transit", transit}
};

This probably isn’t possible but any advice is appreciated.

Regards.

  • 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-09T23:21:05+00:00Added an answer on June 9, 2026 at 11:21 pm

    This would do the trick:

    public class Variable
    {
        public object Value { get; set; }
    }
    

    Then he could do what he is asking, namely:

    Dictionary<string, Variable> dict = new Dictionary<string, Variable>()
    {
        {"Transit", new Variable()}
    }
    
    dict["Transit"].Value = "transit"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: “Least Astonishment” in Python: The Mutable Default Argument I'm finding that dictionary
Possible Duplicate: Modify Struct variable in a Dictionary Why is it that MyStruct test
Possible Duplicate: Cache v.s Session I am using some code that uses HttpRuntime.Cache to
Possible Duplicate: Modifying .NET Dictionary while Enumerating through it I have a dictionary object
Possible Duplicate: Inverse dictionary lookup - Python If I have a dictionary named ref
Possible Duplicate: Sort by key of dictionary inside a dictionary in Python I have
Possible Duplicate: Python dictionary, keep keys/values in same order as declared If I have
Possible Duplicate: “Least Astonishment” in Python: The Mutable Default Argument I'm very confused about
Possible Duplicate: Creating or assigning variables from a dictionary in Python Hello we have
Possible Duplicate: Multi value Dictionary I just need to store 2 value. How can

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.