Last active
June 14, 2018 17:23
-
-
Save d630/d786115c1d01eac73763d4e052db5b2e to your computer and use it in GitHub Desktop.
methods: ref, out, default parameters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace csharp | |
| { | |
| public class Program | |
| { | |
| static int b(int x = 2, int y = 1) | |
| { | |
| return x * y; | |
| } | |
| static void a(int i, ref int ii, out int iii, int x = 3) | |
| { | |
| i *= 2; | |
| ii *= x; | |
| //iii *= 4; | |
| iii = ii * 4; | |
| } | |
| static void Main(string[] args) | |
| { | |
| int i = 5; | |
| a(i, ref i, out i); | |
| Console.WriteLine(i); | |
| i = 5; | |
| a(i, ref i, out i, 2); | |
| Console.WriteLine(i); | |
| Console.WriteLine(b(y: 2)); | |
| Console.ReadKey(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment