Link to home
Start Free TrialLog in
Avatar of n_srikanth4
n_srikanth4Flag for India

asked on

How to find the records which are not in a arraylist

Hi
The explanation is like below.
i have a arraylist which contains
arraylist _upsRange=new arraylist{}
_upsRange array list contains  {"13.11.2009","14.11.2009","18.11.2009"}.
iam building the datecodebasicobj lile below

foreach (IDateCodeBasicDTO val in lineDetails.DateCodeBasics)
                 {
                     DateCodeBasicDTO _dateCode = new DateCodeBasicDTO();
                     if (val.ItemDateCode != null)
                     {
                         _dateCode.CountUnitCode = val.CountUnitCode;
                         _dateCode.IouSize = val.IouSize;
                         _dateCode.ItemDateCode = val.ItemDateCode;
                         _dateCode.LayoutBcode = val.LayoutBcode;
                         _dateCode.LineNumber = val.LineNumber;
                         _dateCode.LocationCode = val.LocationCode;
                         _dateCode.Quantity = val.Quantity;
                         _dateCode.UpdTstmpField = val.UpdTstmpField;
                         datecodeBasicObj.Add(_dateCode);
                     }

                 }

datecodebasicobj {"10.11.2009","11.11.2009","12.11.2009"}."13.11.2009","14.11.2009","18.11.2009"}.
i need to find out  the records in datecodebasicobj which not in upsRange forecastlist.
the output will be {"10.11.2009","11.11.2009","12.11.2009"}
for (int i = 0; i <= _upsRange.Count; i++)
            {
                var datecodelist = from d in datecodeBasicObj
                                   where d.ItemDateCode != _upsRange[0].ToString                                         select d;

            }

pls help me and send the logic for the above code.



codefile.txt
Avatar of xoperator
xoperator
Flag of Israel image

Hi,

Here is the logic that you need, notice that the needed filtered values will be stored in a new list of strings called cleanList.

            List<string> cleanList = new List<string>();

            for (int i = 0; i <= datecodebasicobj.Count; i++)
            {
                for (int x = 0; x <= _upsRange.Count; x++)
                {
                    if(datecodebasicobj[i] != _upsRange[x])
                    {
                        cleanList.Add(datecodebasicobj[i]);
                    }
                }
            }

If you see any compilation errors please tell me, and i will help you ...
ASKER CERTIFIED SOLUTION
Avatar of DmitryVasiliev
DmitryVasiliev
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of n_srikanth4

ASKER

GOOD