VB 6 -> C# Classes technical note...

  • Thread starter Thread starter SpotNet
  • Start date Start date
S

SpotNet

Hello NewsGroupies,

Not a problem nor a show stopper, just want to ask whether a public not
creatable class in VB6 equates to a class of static members in C# (or static
class in the new C# to come). Just built a whole lot of interface classes in
C# and want to allocate the interface to the appropriate implementation via
a 'factory' class, which in VB6 was done using a Public Not Creatable class.

I know it works using statics just asked for self clarification.

Many thanks and Regards,
SpotNet.
 
Hello,

No, they are not equal. Public Not Creatable means that the class interface
is visible to the clients, but the clients cannot instantiate the class.
It's rather like a regular class with a private constructor in C#.
Speaking of factories, you can either make them fully static, or you can
implement the Singleton pattern - in which case there will be only one
static property returning the sole instance of the class, but the rest of
properties and methods will be non-static.
 
Thanks Dmitriy, helps with the transformation from VB6 -> C#.

Regards,
SpotNet

Dmitriy Lapshin said:
Hello,

No, they are not equal. Public Not Creatable means that the class
interface is visible to the clients, but the clients cannot instantiate
the class. It's rather like a regular class with a private constructor in
C#.
Speaking of factories, you can either make them fully static, or you can
implement the Singleton pattern - in which case there will be only one
static property returning the sole instance of the class, but the rest of
properties and methods will be non-static.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

SpotNet said:
Hello NewsGroupies,

Not a problem nor a show stopper, just want to ask whether a public not
creatable class in VB6 equates to a class of static members in C# (or
static
class in the new C# to come). Just built a whole lot of interface classes
in
C# and want to allocate the interface to the appropriate implementation
via
a 'factory' class, which in VB6 was done using a Public Not Creatable
class.

I know it works using statics just asked for self clarification.

Many thanks and Regards,
SpotNet.
 
Back
Top