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 Answer