fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. class ImplicitlyTypedLocals2
  5. {
  6. static void Main()
  7. {
  8. string[] words = { "aPPLE", "BlUeBeRrY", "cHeRry" };
  9.  
  10. // If a query produces a sequence of anonymous types,
  11. // then use var in the foreach statement to access the properties.
  12. var upperLowerWords =
  13. from w in words
  14. select new { Upper = w.ToUpper(), Lower = w.ToLower() };
  15.  
  16. // Execute the query
  17. foreach (var ul in upperLowerWords)
  18. {
  19. Console.WriteLine("Uppercase: {0}, Lowercase: {1}", ul.Upper, ul.Lower);
  20. }
  21. }
  22. }
Success #stdin #stdout 0.04s 34848KB
stdin
Standard input is empty
stdout
Uppercase: APPLE, Lowercase: apple
Uppercase: BLUEBERRY, Lowercase: blueberry
Uppercase: CHERRY, Lowercase: cherry