If you find this article useful, consider making a small donation to show your support for this web site and its content.
DiscountASP
AboutMe
About me:
Hi. My name is Farooq Kaiser and I'm a software developer from Toronto, Canada.

Comparing elements using LINQ query operators

by Farooq Kaiser 9. February 2009 06:29

The Standard Query Operators is an API that enables querying of any .NET array or collection. 

I will compare two folders using query operators. 

         var folder1 = Directory.GetDirectories(@"C:\");

   var folder2 = Directory.GetDirectories(@"C:\Windows");

        // if they are not equal

        if(!folder1.SequenceEqual(folder2))

        {

            //get missing folders

            var Folders = folder1.Except(folder2);

            //iterate the missing folders

foreach (var folder in Folders)

                Response.Write(folder);

          } 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

.NET | API | C#

Comments

Jobs Autos Real estate Videos Power by Google