C# Equivalent of VB's Main() for a DLL

  • Thread starter Thread starter Chan
  • Start date Start date
C

Chan

VB DLL project does the followings:

1> project's Startup Object specifies to run Sub Main() located in a
module (not a class), it simply initialize all variables, for example
assigns values to different passwords. Consider them as private static
variables. So Main() runs before Class_Initialize().

2> then Class_Initizalize() as VB does.

Rewriting this VB project in C#, I'd like to create a similar method
(or something) as VB's Sub Main() so it runs once only. But, static
void Main() is not for DLLs. How can I do it?

A constructor can simply take care of 2> I believe.

Thanks.
 
William Stacey said:
Setup that stuff in a static constructor on one of your classes.

.... and note that the static constructor will only be run when
something uses that class.
 
Back
Top