retrive file line one by one using C#?

Posted by riad on Stack Overflow See other posts from Stack Overflow or by riad
Published on 2010-06-03T11:06:34Z Indexed on 2010/06/03 11:14 UTC
Read the original article Hit count: 245

Filed under:

Dear all,

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 say nameString and address is let 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 their any function in C# as like as explode in php?

thanks in advance
riad

© Stack Overflow or respective owner

Related posts about c#