VB.NET Shared

D

Dean

Hi,

what is the C# equivalent of VB.NET's Shared

e.g.

in VB.NET
Public Shared myColor As Color

does static do the same job?

public static Color myColor;

thanks,
Mori
 
J

Jon Skeet

Dean said:
what is the C# equivalent of VB.NET's Shared

e.g.

in VB.NET
Public Shared myColor As Color

does static do the same job?

public static Color myColor;

I believe so, yes - but I have a pretty limited grasp of VB.NET.
Basically static means that the field (or property, or method) doesn't
apply to a specific instance of the type, it applies to the type as a
whole.
 
B

B. Voronkov

Dean said:
Hi,

what is the C# equivalent of VB.NET's Shared

e.g.

in VB.NET
Public Shared myColor As Color

does static do the same job?

public static Color myColor;

thanks,
Mori

Yes.
 
K

Kumar Gaurav Khanna [.NET MVP]

Hi!

Yes, "static" is the equivalent for VB.NET's "shared" keyword.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top