Click here to Skip to main content
15,908,274 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, I am new to CodeProject and this is my first question please ignore mistakes

I had a string like
C#
string line="abc def ghi jkl";


I am using
C#
Split(' ');
to split the string on the basis of space and I succeed to do this and out put is like
abc<br />
def<br />
ghi<br />
jkl


My question is that how I can get some specific parts of this string after splitting instead of getting all as in my case. I want the output something like that
abc <br />
jkl<br />
Posted

VB
abc
def
ghi
jkl


array=
XML
<pre lang="vb">abc
def
ghi
jkl</pre>


you already have output right so make one loop


string aa='';
for(int i=0;i<array.length;i++)>
{
if(array[i]=="abc" or array[i]=="jkl")
string aa=array[i]+ ','
}
so in aa you get string
 
Share this answer
 
C#
string[] array = line.split(' ');

console.writeline(array[0]);
console.writeline(array[3]);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900