• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 390
  • Last Modified:

Equivalent of VB.NET Modules in C#?

Is there any equivalent of VB.NET modules in C#?

I have a lot of constant variables, which I want to define in a separate file as public const variables.

I want to access these public variables directly without qualifying them with the class name or object name.

This is possible in VB.NET. Can we do a similar thing in C#?
0
rajesh_khater
Asked:
rajesh_khater
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
"without qualifying them with the class name or object name"

No...there is no equivalent of a Module in C#.

The way that "globals" are normally created is to make public static members in a class...so you have to qualify them with the class name.  Sorry...

    clsGlobals.someStaticMember
0
 
REA_ANDREWCommented:
"I want to access these public variables directly without qualifying them with the class name or object name"

surely you can see that using the object name makes for much more structured and manageable code?

imagine designing the same variable name in two separate files, thus ambiguity sets in and you must then distinguise between them anyway.

Andrew
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now