linq Restriction Operators

Where Operators in linq
The Code
static void Main(string[] args)
        {
            int[] numbers = { 50, 45, 165, 38, 96, 8, 62, 70, 21, 0 };
            foreach (int i in numbers)
            {
                Console.Write(i + ", ");
            }
            var result = from n in numbers
                         where n < 50
                         select n;
            Console.WriteLine("\n\n :: Whare with simple conditon");
            Console.WriteLine("Numbers < 50 :");
            foreach (var r in result)
            {
                Console.WriteLine(r);
            }

            Console.WriteLine("\n :: Count with equal conditon");
            var _resultCount = (from n in numbers
                                where n.Equals(0)
                                select n).Count();
            Console.WriteLine("Count number equals 0");
            Console.WriteLine(_resultCount);

            string[] digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };

            var shortDigits = digits.Where((digit, index) => digit.Length < index);
            Console.WriteLine("\n :: Where with Indexed");
            Console.WriteLine("Short digits");
            foreach (var d in shortDigits)
            {
                Console.WriteLine("The word {0} is shorter than its value.", d);
            }
            Console.ReadKey(true);
        }
The Output
linq Restriction Operators linq Restriction Operators Reviewed by Bhaumik Patel on 10:03 PM Rating: 5