473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Global variables in VC#.net windows application

Hi!
I want to use some variables throughout my VC#.net windows based application...........
How can i declare global variables that will work throughout my project...
-Regards
Jan 27 '07 #1
3 4018
kenobewan
4,871 Expert 4TB
I recommend declaring them in the application_start event of the global.asax file. This article may help if you are unfamiliar with the ASP.NET application file:
Global.asax Syntax
Jan 28 '07 #2
almaz
168 Expert 100+
Hi!
I want to use some variables throughout my VC#.net windows based application...........
How can i declare global variables that will work throughout my project...
-Regards
Global variables, especially those being updated from various parts of application, make your code unreadable. General thoughts that should be considered when you want to declare something to be globally available:
  • Each variable is bound to some functionality. Thus, it is better to put it to corresponding class as static/instance member, so it will be maintained through methods/properties of that class.
  • Static members containing common values that are changed from different places of application can brake encapsulation rule.
Nevertheless it may be useful to separate common constants/settings to a separate internal static class, something like this:
Expand|Select|Wrap|Line Numbers
  1. internal static class Constants
  2. {
  3.     public static int UndefinedID = int.MinValue;
  4.  
  5.     public bool IsDefined(int id) { return id != UndefinedID; }
  6. }
  7.  
Jan 29 '07 #3
nmsreddi
366 256MB
hello kenobewan

i want to how you can have a global.asax file in windows based application

as you have said in the above reply.


please tell me if its possible it is very use full for me too.


regards
NMsreddi
Jan 30 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: mark4asp | last post by:
What are the best methods for using global constants and variables? I've noticed that many people put all global constants in a file and include that file on every page. This is the best way of...
2
by: Patient Guy | last post by:
I have a library of functions representing a filesystem interface (essentially a file selection interface, to be used in opening/reading/writing/closing files). Heavily scripted HTML document...
17
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm...
33
by: MLH | last post by:
I've read some posts indicating that having tons of GV's in an Access app is a bad idea. Personally, I love GVs and I use them (possibly abuse them) all the time for everything imaginable - have...
41
by: Miguel Dias Moura | last post by:
Hello, I am working on an ASP.NET / VB page and I created a variable "query": Sub Page_Load(sender As Object, e As System.EventArgs) Dim query as String = String.Empty ... query =...
22
by: fd123456 | last post by:
Hi Tom ! Sorry about the messy quoting, Google is playing tricks on me at the moment. > Global.asax is where you normally have the Global Application > and Session variables and code to...
2
by: Nathan Sokalski | last post by:
I would like to access variables and functions that I declare in the Global.asax.vb file. However, I am having trouble doing that. What does the declaration have to look like in the Global.asax.vb...
1
by: Mukesh_Singh_Nick | last post by:
I am learning classic ASP 3.0. Below are my questions: 1. Do we have to include (<!-- #include FILE="global.asa" -->) the global.asa file into every .asp page? I am doing the examples in Windows...
5
by: Sandman | last post by:
I dont think I understand them. I've read the section on scope in the manual inside out. I'm running PHP 5.2.0 Here is the code I'm working on: //include_me.php <?php $MYVAR = array(); global...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.