c# access modifiers not allowed static constructors code example
Example 1: c# error CS0515
error CS0515: 'Forest.Forest()': static constructor cannot have an
access modifier
/* This error usually means you labeled a static constructor
as public or private, which is not allowed */
public static Forest() //causing error
static Forest() //fixing error
Example 2: static class constructor c#
class SimpleClass
{
// Static variable that must be initialized at run time.
static readonly long baseline;
// Static constructor is called at most one time, before any
// instance constructor is invoked or member is accessed.
static SimpleClass()
{
baseline = DateTime.Now.Ticks;
}
}