Try the following:
using System;
class T
{
static T() { Console.WriteLine("static constructor"); }
}
class Test
{
static void Main()
{
Type t = typeof(T);
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(t.Typ
eHandle);
}
}
Regards,
Jeroen
> -----Original Message-----
> From: The DOTNET list will be retired 7/1/02
> [mailto:[EMAIL PROTECTED]] On Behalf Of Dejan Jelovic
> Sent: Wednesday, June 05, 2002 14:37
> To: [EMAIL PROTECTED]
> Subject: [DOTNET] calling static constructors
>
>
> Is there a way to ensure that a static constructor is called
> for a class
> without creating an instance or calling some other static function?
>
> Thanks,
> Dejan (www.jelovic.com)
>
> You can read messages from the DOTNET archive, unsubscribe
> from DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.
>
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.