コード例 #1
0
 static void ReverseEverything(ProductInfo[] products) {
     Console.WriteLine("=> Products in reverse");
     var allProducts = products.Reverse();
     foreach (var prod in allProducts) {
         Console.WriteLine(prod);
     }
     Console.WriteLine();
 }
コード例 #2
0
 static void SelectProductNames(ProductInfo[] products) {
     Console.WriteLine("=> All Names:");
     var allNames = from p in products select p.Name;
     foreach (var p in allNames) {
         Console.WriteLine(p);
     }
     Console.WriteLine();
 }
コード例 #3
0
 static void GetNamesAndDescriptions(ProductInfo[] products) {
     Console.WriteLine("=> GetNamesAndDescriptions:");
     var nameDesc = from p in products select new { p.Name, p.Description };
     foreach (var p in nameDesc) {
         Console.WriteLine(p);
     }
     Console.WriteLine();
 }
コード例 #4
0
 static void SelectEverything(ProductInfo[] products) {
     Console.WriteLine("=> All producrt details:");
     var allProducts = from p in products select p;
     foreach (var p in allProducts) {
         Console.WriteLine(p);
     }
     Console.WriteLine();
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: usedflax/flaxbox
        static void AlphabetizeProductNames( ProductInfo[] products )
        {
            // Get names of products, alphabetized.
            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());
            }
        }
コード例 #6
0
 static void GetOverstock(ProductInfo[] products) {
     Console.WriteLine("=> GetOverstock");
     var overstock = from p in products 
                     where p.NumberInStock > 25
                     where p.NumberInStock > 25      //works fine
                     select p;
     foreach (var p in overstock) {
         Console.WriteLine(p);
     }
     Console.WriteLine();
 }
コード例 #7
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 items in nameDesc)
         Console.WriteLine(items.ToString());
 }
コード例 #8
0
 static void GetOverstock(ProductInfo[] products)
 {
     Console.WriteLine("The overstock items!");
     var overstock = from p in products where p.NumberInStock > 25 select p;
     foreach (ProductInfo c in overstock)
         Console.WriteLine(c.ToString());
 }
コード例 #9
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);
 }
コード例 #10
0
 static void SelectEverything(ProductInfo[] products)
 {
     Console.WriteLine("All product details:");
     var allProducts = from p in products select p;
     foreach (var prod in allProducts)
         Console.WriteLine(prod.ToString());
 }
コード例 #11
0
ファイル: Program.cs プロジェクト: usedflax/flaxbox
 static Array GetProjectedSubset( ProductInfo[] products )
 {
     var nameDesc = from p in products select new { p.Name, p.Description };
     return nameDesc.ToArray();
 }
コード例 #12
0
ファイル: Program.cs プロジェクト: usedflax/flaxbox
        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)
            {
                // Could also use Name and Description properties directly.
                Console.WriteLine(item.ToString());
            }
        }
コード例 #13
0
        static Array GetProjectedSubset(ProductInfo[] products)
        {
            var nameDesc = from p in products select new { p.Name, p.Description };

            // Mape set of anonymous objects to an Array object.
            return nameDesc.ToArray();
        }
コード例 #14
0
        static void AlphabetizeProductNames(ProductInfo[] products) {
            Console.WriteLine("=> Ordered by Name");
            var subset = from p in products
                         orderby p.Name
                         select p;
            foreach (var p in subset) {
                Console.WriteLine(p);
            }
            Console.WriteLine();

        }
コード例 #15
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());
 }
コード例 #16
0
 static void AlphabetizeProductNames(ProductInfo[] products)
 {
     var subset = from p in products orderby p.Name descending select new {p.Name};
     Console.WriteLine("Ordered by Name:");
     foreach (var p in subset)
         Console.WriteLine(p.ToString());
 }
コード例 #17
0
ファイル: Program.cs プロジェクト: usedflax/flaxbox
        static void GetOverstock( ProductInfo[] products )
        {
            Console.WriteLine("The overstock items!");

            // Get only the items where we have more than
            // 25 in stock.
            var overstock = from p in products where p.NumberInStock > 25 select p;

            foreach (ProductInfo c in overstock)
            {
                Console.WriteLine(c.ToString());
            }
        }