[Mono-list] Creating a singleton value-type

Adam Treat manyoso@yahoo.com
Thu, 6 Jun 2002 00:22:44 -0700


Hello,

I am trying to create a singleton value type for use as a dummy in an 
overoaded constructor.  My question is, if a method passes SNull.Instance as 
a parameter, then I understand that a copy of SNull is made instead of 
passing by reference.  I assume this means that my attempt at a singleton 
value-type has failed...  Anyone have any ideas on how this can be 
accomplished?

using System;

struct SNull {

	private static readonly SNull instance = new SNull (null);

	private SNull (Object dummy) {}

	internal static SNull Instance {
		get {return instance;}
	}
}

Cheers,

Adam