Hey Guys,
as mentionned in the title,in c# if 2 lines have same first characters how can i delete second one?!
lines like this:
url1/page1/title1/number1
url1/page1/title1/number2
wanna keep the first link and delete the second one,any idea?
lets expand it
arl1/page1/title1/number1
brl1/page1/title1/number2
crl1/page1/title1/number1
drl1/page1/title1/number2
erl1/page1/title1/number1
frl1/page1/title1/number2
url1/page1/title1/number1 <start with "u"
url1/page1/title1/number2 <start with "u", this line will be remove
grl1/page1/title1/number1
hrl1/page1/title1/number2
irl1/page1/title1/number1
jrl1/page1/title1/number2
krl1/page1/title1/number1
lrl1/page1/title1/number2
1. Make a list (or array) of that line as string
2. Loop that entire list
3. Store the 'i' element and get its first char
4. Store the 'i+1' element and get its first char
5. Compare the first char of 'i' and 'i+1' element
5. If same, remove 'i+1' element
here how it look with code: (not excactly work with this code, just how it look)
PHP:
list() //an array that contains all that lines;
var curentline //the 'i' element;
var nextline // the 'i+1' element
for (i=0; i < (list.count - 1); i++){
curentline = list(i);
if (i+1 <= list.count-1){
nextline = list(i+1);
fisrtchar1 = curentline(0); //get the fisr char of the curent line, you may need to convert string to array
fisrtchar2 = nextline(0); //get the fisr char of the next line, you may need to convert string to array
if (fisrtchar1 == fisrtchar2){
//remove the element list(i+1), this may effect the loop, so it better just to store the element info and remove it latter
}
}else{
nextline = empty;
}
}