String manipulation (PHP explode() like function)

  • Thread starter Thread starter FrzzMan
  • Start date Start date
F

FrzzMan

Hello,

If I have a string "abc.def.ghi"

Is there any simple way to explode it to an array like PHP explode()
function?

Like this:

/* This is not C# code */
string Data = "abc.def.ghi";
string[] Ret = explode(Data);

/* Ret will contain:
Ret[0] = "abc"
Ret[1] = "def"
Ret[2] = "ghi"
So that I can reverse the string easily */

Actually, I want to change the string "abc.def.ghi" to "ghi.def.abc"
 
using the "Split" method of "String" class:



string test = "abc.def.ghi";

string [] result = test.Split(new Char[] {'.'});

for (int i = 0; i < result.Length; i++)

{

Console.WriteLine(result);

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top