Select with Anonymous Types: prints uppercase and lowercase versions of each string in an input array : select « LINQ « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass {
    public static void Main() {

        string[] words = { "Abc", "aBc", "AAA" };

        var upperLowerWords =
            from w in words
            select new { Upper = w.ToUpper(), Lower = w.ToLower() };

        foreach (var ul in upperLowerWords) {
            Console.WriteLine("Uppercase: {0}, Lowercase: {1}", ul.Upper, ul.Lower);
        }
    }
}








22.63.select
22.63.1.Query Reuse
22.63.2.Select array item by type
22.63.3.Use LINQ with Dictionary
22.63.4.Use LINQ to query characters in a string
22.63.5.Transformation: link two array.
22.63.6.Select with Anonymous Types: prints uppercase and lowercase versions of each string in an input array
22.63.7.Select with Anonymous Types: iterates over each element to print the element's name
22.63.8.Select with Anonymous Types: prints the name of every product in the product list along with the category of the product and its unit price
22.63.9.Using select to create a sequence of each product name.
22.63.10.Converting an Array of Strings to Integers
22.63.11.Converting an Array of Strings to Integers and Sorting It
22.63.12.Query with Intentional Exception Deferred Until Enumeration
22.63.13.Demonstrating the Query Results Changing Between Enumerations
22.63.14.Returning a List
22.63.15.Select Distinct
22.63.16.Select all from a List
22.63.17.Select only pet name
22.63.18.Select sum value
22.63.19.Delegate targets
22.63.20.Adding new line character to selected value