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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:27:38+00:00 2026-06-06T13:27:38+00:00

So I have a anonymous type which I have used ToString on, and put

  • 0

So I have a anonymous type which I have used ToString on, and put into a file. It looks like this (and remarkably like JSon…):

{ Name = Name, Description = Description, Status = Pending, Key = Template, SubmittedBy = MyName, Identity = 2fb7a40b-e07a-4f1a-a48b-2c2720567f35 }

now I want to go the other way (edit:take the string from a file and put it into a format I can put into a known object) and put it into an anonymous type (which has the same properties, but I don’t care if they are castable or anything like that, I just want a quick way to do something like.

AnonObject = GetObjectFromFile(blah);
RealObject.Name = AnonObject.Name;

I only have an interface for RealObject, so I can’t add serialisation to the class. If you know a better way, let me know.
Thanks.

  • 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-06T13:27:39+00:00Added an answer on June 6, 2026 at 1:27 pm

    Anonymous types are defined at compile time, and included in the assembly just like any other type. Creating them at execution time would require dynamically creating types – it’s likely to end up getting messy really quickly.

    If you’re using .NET 4, you could use an ExpandoObject and dynamic; otherwise I’d probably just use a Dictionary<string, object> and change this:

    RealObject.Name = AnonObject.Name;
    

    to

    RealObject["Name"] = AnonObject.Name;
    

    (Or vice versa. It’s not really clear what you’re doing.)

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

Sidebar

Related Questions

Say I have a LINQ-to-XML query that generates an anonymous type like this: var
We have this anonymous function in our code, which is part of the jQuery's
I have a simple ajax call like this: $.ajax({ url: u, type: POST, dataType:
I have a nested list that looks like this: mylist = [['A;B', 'C'], ['D;E',
I have the following XML document which I would like to parse into a
I have a Linq query that returns an anonymous type, which I then use
I have an item object that looks like this: item[siteId] = {7BAD6B24-3B69-4CB9-AD02-9B0003C1927D}; item[webId] =
In our code we used to have something like this: *(controller->bigstruct) = ( struct
I have a function that returns an anonymous type which I want to test
I have an anonymous type object that I receive as a dynamic from 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.