Equivalent of VB.NET Modules in C#?

Posted on 2007-07-25
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 85

    Accepted Solution

    "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 you have to qualify them with the class name.  Sorry...

    LVL 20

    Expert Comment

    "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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    794 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now