Simple L I N Q Example C# with Example



Simple L I N Q 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 = from n in numbers where n > 0 select n;
            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