Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
C# Reference Types
using System;
using System.Collections.Generic;
namespace hwapp
{
class Program
{
static void Main(string[] args)
{
var m = new Dictionary<int, int>();
m[0] = 110;
show(m);
remakeMap(ref m);
show(m);
}
static void show(Dictionary<int, int> m)
{
foreach (var kv in m)
{
Console.WriteLine(kv);
}
}
static void mutateMap(Dictionary<int, int> m)
{
m[0] = 66;
}
static void remakeMap(ref Dictionary<int, int> m)
{
m = new Dictionary<int, int>();
m[10] = 10;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment