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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:32:54+00:00 2026-05-14T16:32:54+00:00

I need a sensible way to draw arbitrary text files into a C# program,

  • 0

I need a sensible way to draw arbitrary text files into a C# program, and produce an arbitrary anonymous type object, or perhaps a composite dictionary of some sort.

I have a representative text file that looks like this:

adapter 1: LPe11002
  Factory IEEE: 10000000 C97A83FC
  Non-Volatile WWPN: 10000000 C93D6A8A , WWNN: 20000000 C93D6A8A
adapter 2: LPe11002
  Factory IEEE: 10000000 C97A83FD
  Non-Volatile WWPN: 10000000 C93D6A8B , WWNN: 20000000 C93D6A8B

Is there a way to get this information into an anonymous type object or some similar structure?

The final anonymous type might look something like this, if it were composed in C# by hand:

new
{
    adapter1 = new 
    { 
        FactoryIEEE = "10000000 C97A83FC",
        Non-VolatileWWPN = "10000000 C93D6A8A",
        WWNN = "20000000 C93D6A8A"
    }
    adapter2 = new 
    { 
        FactoryIEEE = "10000000 C97A83FD",
        Non-VolatileWWPN = "10000000 C93D6A8B",
        WWNN = "20000000 C93D6A8B"
    }
}

Note that, as the text file’s content is arbitrary (i.e. the keys could be anything), a specialized solution (e.g. that looks for names like “FactoryIEEE”) won’t work. However, the structure of the file will always be the same (i.e. indentation for groups, colons and commas as delimiters, etc).

Or maybe I’m going about this the wrong way, and you have a better idea?

  • 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-14T16:32:54+00:00Added an answer on May 14, 2026 at 4:32 pm

    You’re going about this the wrong way. Your “anonymous type object” data is hard to construct and hard to use. To construct it, you’d have to use reflection trickery. And for what?

    Consider a PrintReport function. This function would not get any simpler because of the ATO usage. Far from it, it’d get more complicated and slow, having to use reflection itself to iterate over the keys. Your solution might have made sense if there was a small, fixed number of possible keys. Then usage syntax such as “obj.FactoryIEEE” might have been preferred.

    The way I’d go about this is with a List<Dictionary<string, string>>, or, say a List<AdapterRecord> where AdapterRecord is

    class AdapterRecord
    {
        public string Name { get; set; }
        public Dictionary<string, string> Parameters { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We need to find a sensible way to manage our in-house .NET libraries that
what is the best way of extracting multiple (~40 values) from a text file
I have a long document in XML from which I need to produce static
My method accepts a Method object as a parameter. Therefore, I need to create
I need to write a server program that will open and keep 5 live
I have a lowercase thorn separated file that I need to load into a
Need to apply a filter to a file like this: TUPAC_0006:1:1:2554:2356#0/1 0 * 0
Need a map reduce function by mongo in php This my mongo structure [_id]
Need some regular expressions help. So far I have my code working to allow
Need help, function getFamily() { FB.api('/me/family', function(response) { alert(JSON.stringify(response)); }); } With the above

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.