.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Generics >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Compare Two ArrayList with DateTime

Posted By:Narayanan       Posted Date: November 02, 2012    Points: 40    Category: Generics    URL: http://www.dotnetspark.com  

Here , The following code is for Compare Two ArrayList with DateTime using C#.net
 

Here , The following code is for Compare Two ArrayList with DateTime using C#.net
  private static ArrayList list1 = new ArrayList(new DateTime[] { Convert.ToDateTime("2010-12-01"), Convert.ToDateTime("2010-12-11"), Convert.ToDateTime("2010-12-21") });
        private static  ArrayList list2 = new ArrayList(new DateTime[] { Convert.ToDateTime("2010-12-01"), Convert.ToDateTime("2010-12-15") });
        private static int CountofList1 = list1.Count;
        private static int CountofList2 = list2.Count;
        private static void CompareDatewithArrayList(string Comp)
        {
            switch (Comp)
            {
                case "1":
                   
                   
                    if (CountofList1 > CountofList2)
                    {
                        foreach (DateTime str in list1)
                        {
                            if (!list2.Contains(str))
                            {
                                MessageBox.Show(Convert.ToString(str));
                            }
                        }
                    }
                    else if (CountofList1 == CountofList2)
                    {
                        foreach (DateTime str in list1)
                        {
                            if (!list2.Contains(str))
                            {
                                MessageBox.Show(Convert.ToString(str));
                            }
                        }
                    }

                    else
                    {
                        foreach (DateTime str in list1)
                        {
                            if (!list2.Contains(str))
                            {
                                MessageBox.Show(Convert.ToString(str));
                            }
                        }
                    }

                    break;
                case "2":
                    
                    
                    if (CountofList1 > CountofList2)
                    {
                        foreach (DateTime str in list2)
                        {
                            if (!list1.Contains(str))
                            {
                                MessageBox.Show(Convert.ToString(str));
                            }
                        }
                    }
                    else if (CountofList1 == CountofList2)
                    {
                        foreach (DateTime str in list2)
                        {
                            if (!list1.Contains(str))
                            {
                                MessageBox.Show(Convert.ToString(str));
                            }
                        }
                    }

                    else
                    {
                        foreach (DateTime str in list2)
                        {
                            if (!list1.Contains(str))
                            {
                                MessageBox.Show(Convert.ToString(str));
                            }
                        }
                    }

                    break;
            }
                    }


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend