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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:56:26+00:00 2026-05-15T03:56:26+00:00

I have a text file named abc.txt . The file have info like this

  • 0

I have a text file named abc.txt. The file have info like this

jani
stay in USA
karim
stay in France
fara
stay in UK

The code needs to read the file from beginning and read the first line and put it to in a string let nameString. Then it read the second line and put the info to a another string let name addressString. Then it read the third line and put the info into nameString and then forth line and put the info as addressString. Like this way it will continue up to the end of file. I have to put those information on anywhere else. So, I need all the name and address in a for loop.

Can anybody pls help me to collect this info.

Thanks in advance
Riad

  • 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-15T03:56:26+00:00Added an answer on May 15, 2026 at 3:56 am

    Here we go

     StreamReader SR;
     string S;
     SR = File.OpenText(filename);
     S = SR.ReadLine();
     string name = "";
     string address = "";
     counter = 1;
     while (S != null)
     {
        if ((counter % 2) != 0)
           name = S;
        else
           address = S;
    
        //do what you want with name and address here
    
        S = SR.ReadLine();
        counter++;
    
     }
     SR.Close();
    

    Make sense?

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

Sidebar

Related Questions

I have a text file named num.txt who's only contents is the line 123
I have a text file which contains something like this: Hello, my name is
I have a text file named C:/test.txt : 1 2 3 4 5 6
i have a text file named file.txt. and the contents of file.txt is as
I have a text file named settings.txt . Inside it i have it saying:
I have a text file named Se7enPlug.dspl . In this file I have only
I have a text file which is named test.txt . I want to read
I have an xml file that looks like this: <args> <sometag value=abc /> <anothertag
I have this xml file which has text init. i.e Hi my name is
I have an .erb file where I'd like to return the following text: Name

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.