hello frndz,
I need a help in concatening a string in c#.
the string is ||'001089||' !:122003396!: 3240058971||'
it should look like exactly like
Number1=001089
Number2=122003396
Number3=3240058971
i know that itz not going to be very easy. but we gpt lot of intelligent guyz out here in cSharp corner.
plz help me
thanks n reagards
kumar
AlanPosted Nov 16, 2007, 4:49 AM
To be honest, kumar, this isn't particularly difficult as string parsing goes. The main problem is to decide what the delimiters are for each number. Anyway, I'd suggest something like the following (.NET 2.0 or above assumed):
using System;
class Test
{
static void Main()
{
string s = "||'001089||' !:122003396!: 3240058971||'";
s = s.Replace("||'","").Replace("!:","");
string[] sa = s.Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);
for(int i = 0; i < sa.Length; i++)
{
Console.WriteLine("Number{0}={1}", i+1, sa[i]);
}
Console.ReadKey();
}
}