Equivalent of VB.NET Modules in C#?

Posted on 2007-07-25
Medium Priority
Last Modified: 2010-04-15
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#?
Question by:rajesh_khater
LVL 86

Accepted Solution

Mike Tomlinson earned 2000 total points
ID: 19566097
"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...

LVL 20

Expert Comment

ID: 19566770
"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.


Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Loops Section Overview
Suggested Courses
Course of the Month16 days, 3 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question