Method Query Example C# with Example



Method Query Example C# with Example

 using System;
using System.Linq;

namespace CSharpLINQ
{
    class SimpleQuery
    {
        static void Main()
        {
            int[] numbers = { 1, -2, 3, 0, -4, 5 };

            // Create a query that obtains only positive numbers.
            var posNums = numbers.Where(n => n > 0).Select(r => r);
			
            Console.Write("The positive values in numbers: ");

            // Execute the query and display the results.
            foreach (var i in posNums) Console.Write(i + " ");
        }
    }
}
 

0 Comment's

Comment Form

Submit Comment