Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- namespace Recursion
- {
- class Program
- {
- static void test1(ref int i)
- {
- i++;
- if (i > 5)
- {
- return;
- }
- Debug.WriteLine(string.Format("Before {0}", i));
- test1(ref i);
- Debug.WriteLine(string.Format("After {0}", i));
- }
- static void test2(int i)
- {
- i++;
- if (i > 5)
- {
- return;
- }
- Debug.WriteLine(string.Format("Before {0}", i));
- test2(i);
- Debug.WriteLine(string.Format("After {0}", i));
- }
- static void Main(string[] args)
- {
- int i = 0;
- test1(ref i);
- Debug.WriteLine(string.Empty);
- test2(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement