Skip to content

Instantly share code, notes, and snippets.

@EgorBo
Created May 23, 2017 14:14
Show Gist options
  • Save EgorBo/aa3ac66bef7977d7c6bff1195cf9226c to your computer and use it in GitHub Desktop.
Save EgorBo/aa3ac66bef7977d7c6bff1195cf9226c to your computer and use it in GitHub Desktop.
using System;
namespace StaticTest
{
public class Program
{
public static void Main(string[] args)
{
//args are empty but .NET and MONO will init Foo anyway, .NET core - won't.
var obj = args.Length > 0 ? Foo.Instance : null;
Console.WriteLine(obj);
}
}
public class Foo
{
public static Foo Instance = new Foo();
//static Foo() {}
public Foo()
{
Console.WriteLine("Foo init.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment