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


Top 5 Contributors of the Month
david stephan

Post New Resource Bookmark and Share   

Example of index comparing in Lambda expressions

Posted By:Jean Paul       Posted Date: May 01, 2011    Points: 40    Category:    URL: http://www.dotnetspark.com  

Example of index comparing in Lambda expressions
 

static void Main(string[] args)
        {
            IList list = new List();

            list.Add(0); // Value = Index
            list.Add(2);
            list.Add(2); // Value = Index
            list.Add(1);
            list.Add(4); // Value = Index

            // Lambda code
            var sublist = list.Where((i, ix) => i == ix);

            // Print result
            Console.WriteLine("Lambda Solution");
            foreach (int i in sublist)
                Console.WriteLine(i);

            // Read key and exit
            Console.ReadKey(false);
        }

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Here

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