Solved

VB.NET console app needs to share it's module level public variables

Posted on 2008-10-30
2
354 Views
Last Modified: 2012-05-05
I have a console application that creates several objects which are instantiated classes which are part of the solution.  How can I share a console level variable between other class/dlls without passing the value into the class via something like sub new (myValues as someSetOfSharedValues)?

0
Comment
Question by:hbash
2 Comments
 
LVL 15

Expert Comment

by:David L. Hansen
Comment Utility
making the variables public will do it..but I'd suggest "Friend" (it's like public but a bit more secure).  The other idea is to use a database as the middleman between the different objects (if it makes sence to do that).
0
 
LVL 18

Accepted Solution

by:
Priest04 earned 500 total points
Comment Utility
You showed an example that you want to pass variables through constructor. Yes, you can do that, just make a class constructor that accepts these variables.

Other way would be to have variables shared (static in c#). This can be done either by creating a shared class, or by creating a module, and having public fields (variables) in it. This fields will be visible everywhere in application, so you don't need to pass them in constructor.

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
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…

744 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

17 Experts available now in Live!

Get 1:1 Help Now