Beispiel #1
0
 public static void ForeachWithCapturedVariable(List <int> items)
 {
     foreach (int item in items)
     {
         int c = item;
         Loops.Operation(() => c == 5);
     }
 }
Beispiel #2
0
 public static void ForeachWithRefUsage(List <int> items)
 {
     foreach (int item in items)
     {
         int current = item;
         Loops.Operation(ref current);
     }
 }
Beispiel #3
0
        public static void ForeachWithRefUsage(List <int> items)
        {
            foreach (int item in items)
            {
#if ROSLYN && OPT
                // The variable name differs based on whether roslyn optimizes out the 'item' variable
                int current = item;
                Loops.Operation(ref current);
#else
                int num = item;
                Loops.Operation(ref num);
#endif
            }
        }