Пример #1
0
 static void ReverseEverything(ProductInfo[] products)
 {
     Console.WriteLine("Product in reverse");
     var allProducts = from p in products select p;
     foreach (var prod in allProducts.Reverse())
     {
         Console.WriteLine(prod.ToString());
     }
 }
Пример #2
0
        static void AlphabetizeProductNames(ProductInfo[] products)
        {
            var subset = from p in products orderby p.Name select p;

            Console.WriteLine("Ordered by Name: ");
            foreach(var p in subset)
            {
                Console.WriteLine(p.ToString());
            }
        }
Пример #3
0
        static void GetNamesAndDescriptions(ProductInfo[] products)
        {
            Console.WriteLine("NAmes and Descriptions: ");
            var nameDesc = from p in products select new { p.Name, p.Description };

            foreach (var item in nameDesc)
            {
                Console.WriteLine(item.ToString());
            }
        }
Пример #4
0
        static void ListProductNames(ProductInfo[] products)
        {
            Console.WriteLine("Only Product Names:");
            var names = from p in products select p.Name;

            foreach (var n in names)
            {
                Console.WriteLine("Name : {0}", n);
            }
        }
Пример #5
0
        static void SelectEverything(ProductInfo[] products)
        { 
            //get everything
            Console.WriteLine("All product details : ");
            var allProducts = from p in products select p;

            foreach (var prod in allProducts)
            {
                Console.WriteLine(prod.ToString());
            }
        }
Пример #6
0
        static void GetOverstock(ProductInfo[] products)
        {
            Console.WriteLine("The Overstock items!");

            //25 ten buyuk olan itemleri al
            var overstock = from p in products
                            where p.NumberInStock > 25
                            select p;
            foreach (ProductInfo c in overstock)
            {
                Console.WriteLine(c.ToString());
            }
        }
Пример #7
0
 static Array GetProjectedSubset(ProductInfo[] products)
 {
     var nameDesc = from p in products select new { p.Name, p.Description };
     return nameDesc.ToArray();
 }