I am having a string in CSV format. Please see my earlier question
Parsing CSV string and binding it to listbox
I can add new values to it by some mechanism. Everything will be same except the new values will have numeric part = 0. Take example
I have this exsiting CSV string
1 , abc.txt , 2 , def.doc , 3 , flyaway.txt
Now by some mechanism i added two more files Superman.txt and Spiderman.txt to the existing string. Now it became
1 , abc.txt , 2 , def.doc , 3 , flyaway.txt, 0, Superman.txt, 0 , Spiderman.txt
What i am doing here is that this csv string is paased into SP where its splitted and inserted to db. So for inserting I have to take the files with numeric part 0 only rest will be omiited .Which will be further then converted into CSV string
Array will look like this
str[0]="1"
str[1]="abc.txt"
str[2]="2"
str[3]="def.doc "
str[4]="3"
str[5]="flyaway.txt"
str[6]="0"
str[7]="Superman.txt"
str[8]="0"
str[9]="Spiderman.txt"
So at last i want to say my input will be
1 , abc.txt , 2 , def.doc , 3 , flyaway.txt, 0, Superman.txt, 0 , Spiderman.txt
Desired Output:
0, Superman.txt, 0 , Spiderman.txt
If your new values are always being added to the end of the input, all you need to do is search the string for the first
0and then return it and everything after it usingstring.Substring(Int32).