In datatable if the value is -ve and +ve remove it

I have a query in datatable if the value is -ve and +ve remove it ,if it is +ve and -ve donot remove it

For example

Value

-915.31
915.31
914.31
-914.31
914.31
915.31
915.31
915.31

My output should be

Value
914.31
915.31
915.31
915.31

Since in input datatable row 1 and 2 value is -ve and + ve it should be removed.row 4and 5value is -ve and +ve it should not be removed

Another example:
Value
915.31
-915.31
915.31
915.31
915.31

My output should be
Value
915.31
915.31
915.31

The row 2 and 3 is removed because it is -ve and +ve value

@sruthesanju
Hello
I think more information is needed, what determines if it is +ve or -ve, is there another column?

Regards

Only one column will be there

@sruthesanju
What determines whether it is +ve or -ve?

Nothing determine the value.based on the sign in the value column we need to remove it

Any idea on this how to develop this scenario.any updates

Hello Sruthesanju,

You have to run a loop maintaining previous and current rows.
And do the validations there. for eg Cheking Current One is Positive +ve and previous one is negative etc.

Then mark there row indexes for removal, and using another loop remove them.

Regards
Ankit

Can you explain with the code

Hello here is a psudo code :

foreach(DataRow dr in dt.Rows)
{

            int index = dt.Rows.IndexOf(dr);
            if (index ==1)
            {
                continue;
            }
                String previous_Val = Convert.ToString(dt.Rows[index-1]);
            String cur_Val = Convert.ToString(dt.Rows[index]);

            if(previous_Val.Contains("-"))
            {
                previous_Val.Replace("-","").Equals(cur_Val);
                // Add index-1 and index to a list 

            }
        }
    // remove rows at these indexes using a while loop

Hope it helps

Regards
Ankit