Skip to content

Instantly share code, notes, and snippets.

@d630
Last active June 14, 2018 17:23
Show Gist options
  • Save d630/d786115c1d01eac73763d4e052db5b2e to your computer and use it in GitHub Desktop.
Save d630/d786115c1d01eac73763d4e052db5b2e to your computer and use it in GitHub Desktop.
methods: ref, out, default parameters
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