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

The Archive Base Latest Questions

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

I have a file name abc.txt . On that file have some lines like

  • 0

I have a file name abc.txt. On that file have some lines like this:

jani
50,south carolina,USA
karim
16,roam,Italy
fara
52,sydny,Australia

First line is name and second line is address. Now I need the info name on a string let’s say nameString and address is let’s say addressString. How can I do it using C#?
I write a code in PHP its working smoothly. I need the same thing in C#. For yours clarification here is the php code:

$file=file_get_contents('abc.txt');

$arr=explode("\n",$file);
for ($i=0;$i<count($arr);$i=$i+2)
{

    $name=$arr[$i];
    $address=$arr[$i+1];
    echo $name ."<br/>";
    echo $address. "<br/>";

}

How can I do the same thing in C#????
Another question: Is there any function in C# as like as explode in php?

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:33:27+00:00Added an answer on May 15, 2026 at 3:33 am
    string[] arr = System.IO.File.ReadAllLines(filename)
    for (int i = 0; i<arr.Length; i += 2)
    {
      // do whatever you need here
    }
    
    • 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 abc.txt . The file have info like this
I have been given some file name which can be like <filename>YYYYMMDD<fileextension> some valid
Consider I have a .txt file as of the format, Name: Abc Id: 123
i have a file name that contains spaces: bw3 - Copy_1340627264571.jpg and i use
I have a file name logspath.txt which contain on the logs directory path on
I have this method for grabbing the file name from a string URI. What
I have a gridview whose one column has value file name and that column
I have a .csv file with data like this: uc007ayl.1,ENSMUSG00000041439 uc009mkn.1,ENSMUSG00000031708 uc009mkn.1,ENSMUSG00000035491 I have
Consider i have a file, 'emp.txt' whose content is, EmpNo. Name Phone No. Salary
I have created JAVA GUI that will receive text file(.txt) from other client and

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.