Skip to content

Instantly share code, notes, and snippets.

@PeteGoo
Last active December 14, 2015 06:39
Show Gist options
  • Save PeteGoo/5043985 to your computer and use it in GitHub Desktop.
Save PeteGoo/5043985 to your computer and use it in GitHub Desktop.
a:
b:
setting a = a1
a: a1
b:
setting b = b1
a: a1
b: b1
setting a = b1
a: a2
b: b1
setting b = b2
a: a2
b: b2
class Program {
static void Main(string[] args) {
WriteValues();
Console.WriteLine("setting a = a1");
Foo<int>.SharedValue = "a1";
WriteValues();
Console.WriteLine("setting b = b1");
Foo<string>.SharedValue = "b1";
WriteValues();
Console.WriteLine("setting a = a2");
Foo<int>.SharedValue = "a2";
WriteValues();
Console.WriteLine("setting b = b2");
Foo<string>.SharedValue = "b2";
WriteValues();
}
private static void WriteValues() {
Console.WriteLine("a: {0}", Foo<int>.SharedValue);
Console.WriteLine("b: {0}", Foo<string>.SharedValue);
}
}
internal class Foo<T> {
public static string SharedValue = "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment