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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:44:15+00:00 2026-05-19T14:44:15+00:00

Using JavaScript it’s possible to access an object using the dot notation or array

  • 0

Using JavaScript it’s possible to access an object using the dot notation or array notation.

var myArray = {e1:"elem1",e2:"elem2",e3:"elem3",e4:"elem4"};
var val1 = myArray["e1"];
var val2 = myArray.e1;

Is it possible to accomplish this using C#?

This is what I have attempted:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(int id, FormCollection frmVals)
{
  string value;
  Owner owner = new Owner();

  foreach (var key in frmVals.AllKeys)
  {
    value = frmVals[key];
    owner[key] = value;  
  }
}
  • 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-19T14:44:16+00:00Added an answer on May 19, 2026 at 2:44 pm

    While there is no way to do this exactly with C#. You could change your code in several ways that may accomplish your goal. First, you could use a Dictionary like this:

    var something = new Dictionary<string, object>() {
        { "property", "value"},
        { "property1", 1}
    };
    foreach (var keyVal in something) {
        var property = keyVal.Key;
        var propertyValue = keyVal.Value;
    }
    

    Another option would be to do it dynamically:

    dynamic somethingDyn = new System.Dynamic.ExpandoObject();
    somethingDyn.property = "value";
    somethingDyn.property1 = 1;
    
    var somethingDynDict = (IDictionary<string, object>)somethingDyn;
    var propValue = somethingDyn["property"];
    
    foreach (var keyVal in somethingDynDict) {
        var property = keyVal.Key;
        var propertyValue = keyVal.Value;
    }
    

    If you need to iterate through properties on a strongly typed object you could use reflection:

    var owner = new Metis.Domain.User();
    var properties = owner.GetType().GetProperties();
    foreach (var prop in properties) {
        object value = prop.GetValue(owner, null);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Javascript, how can I access a specific child of a row? Javascript (not
Using Javascript is it possible to listen for browser's file open/save dialog box event.
Using Javascript. I'm trying to loop through an array encoded with JSON. Here is
Using javascript/jQuery: I have an array with images and I need to display them
I'm currently using javascript eval() to check and create a multidimensional object that I
I'm using javascript, and I have an array containing multiple values, which may be
Without using Javascript, is there a way to make a CSS property toggle on
I'm using JavaScript to hide an image and show some text thats hidden under
I need to edit (using javascript) an SVG document embedded in an html page.
I am using JavaScript and jQuery. My main file has My.js and Ajax. My.js

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.