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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:27:23+00:00 2026-06-09T12:27:23+00:00

There are some cool classes and tricks and short cuts in C#. I know

  • 0

There are some cool classes and tricks and short cuts in C#. I know this but I have not worked with C# enough to have them memoried.

One cool trick is this. If you read from a file data that is arranged in a similar line-by-line structure where each line is arranged in columns spaced out by tabs, the data can be read into a kind of class in C# and then you can parse out one column of data by simply doing a “for each” command. Does anyone know off-hand how this is done?

Basically, what I am talking about is this. I understand how to read a file line by line:

int counter = 0;
string line;
System.IO.StreamReader file =
   new System.IO.StreamReader(filename);

while ((line = file.ReadLine()) != null)
{
    Console.WriteLine(line);
    counter++;
}

file.Close();

Now, how would I go about replacing Console.WriteLine(line); with code that will organize the data automatically into members of a class provided that the line columns in the input file are seperated by /t (tabs)?

  • 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-09T12:27:24+00:00Added an answer on June 9, 2026 at 12:27 pm

    You can call line.Split('\t') This will give you string[] array. You can then parse each element to proper data type.

    MyData LineToMyData(string line)
    {
        try
        {
            string[] arr = line.Split('\t');
    
            return new MyData()
            {
                Time = DateTime.Parse(arr[0]),
                Name = arr[1],
                Age = Int32.Parse(arr[2])
            };
        }
        catch (Exception ex)
        {
            throw new ArgumentException("line", ex);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking to modernize my web development with some cool libraries, but there are
I have a number of atomic classes (Components/Mixins, not really sure what to call
Is there some cool Moria like theme for Visual Studio 2010? Mine is highlighting
I'm looking for some cool libraries out there to display a bunch of images
I am reasonably new to Wordpress custom themes but I do have some knowlege
Before I start, I know there is this post and it doesn't answer my
do you know some cool java library for Apache Wicket, which be able to
Is there a way to use Bluetooth from the iPhone SDK? I have some
I have looked over the web and found some cool examples of MVC implementation
I know there are incredible set of tools for loading plugin classes in java,

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.