fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Reflection;
  6.  
  7.  
  8. public class ABC
  9. {
  10. public int Value { get; private set; }
  11. }
  12.  
  13. internal class Program
  14. {
  15. static void Main()
  16. {
  17. Expression<Func<ABC, int>> expr = abc => abc.Value;
  18.  
  19. Console.WriteLine(((expr.Body as MemberExpression).Member as PropertyInfo).Name);
  20. Yoba(5).ToList().ForEach(Console.WriteLine);
  21. }
  22.  
  23. private static IEnumerable<int> Yoba(int x)
  24. {
  25. if (x < 10)
  26. yield return 2;
  27.  
  28. foreach (var v in Enumerable.Range(3, 9))
  29. {
  30. yield return v;
  31. }
  32.  
  33.  
  34.  
  35. if (x > 3)
  36. yield return 5;
  37. }
  38. }
  39.  
Success #stdin #stdout 0.04s 37208KB
stdin
Standard input is empty
stdout
Value
2
3
4
5
6
7
8
9
10
11
5