473,387 Members | 1,486 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,387 software developers and data experts.

globa variable for windows C# application


hello,

how can i write and read a global variable for the entire application in
C#?
Many Thanks,
Jassim Rahma

*** Sent via Developersdex http://www.developersdex.com ***
Feb 18 '06 #1
2 1356
Hello, Jassim!

JR> how can i write and read a global variable for the entire application
JR> in C#?

Since you cannot define variable on the namespace level, then the solution can be creation of a class with public static variables.

internal class GlobalVars
{
public static int GlobalVar1;
public static string GlobalVar2;
}

However, you should be carefull with this vars if you're working in the multithreaded environment.
A solution here can be substitution of vars with properties, where the neede sync will happen.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Feb 18 '06 #2
Hello Jassim,

General, all common things locates in separate namespace for project, smth
like <Company>.<Project>.Common
As Vadim mentions you need to locate separate class for global variables,
and put it in your common namespace

JR> how can i write and read a global variable for the entire
JR> application in C#?
JR>
JR> Many Thanks,
JR> Jassim Rahma

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Feb 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: refer_to_website | last post by:
How can I retain the value in memory in the ASP.NET Web application? NOTE: This example works correctly (increments the value) when the you create a VB.NET Windows Application, but does not work...
4
by: Gery D. Dorazio | last post by:
Gurus, If a static variable is defined in a class what is the scope of the variable resolved to for it to remain 'static'? For instance, lets say I create a class library assembly that is...
1
by: Aaron | last post by:
Is it the same as cache in asp.net? how do you load an app var in asp.net (C#)? Can you use app variable in a windows app?(.exe) thanks
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 =...
5
by: Anonymous | last post by:
I created a web page that everytime I open the page, the treeview gets populated with literally thousands of data, taking more than three minutes to create the page. I am beginning to find this...
2
by: Oberon | last post by:
Why does this not work as it should? I expect index.aspx to show:. Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\ChatSimple\db\chatusers.mdb Instead, I get: ...
1
by: ad | last post by:
I add the code in the Application_Start of Global.asas void Application_Start(Object sender, EventArgs e) { Hashtable _SystemSet = new Hashtable(); SqlDataReader dr = DM.ExecuteReader("SELECT...
5
by: nmsreddi | last post by:
hello i am developing c# windows application where i got a requirement of using the login name through out my application. even i have created a variable as public and i am able to...
1
by: sap0321 | last post by:
This should be kindergarten stuff but for some reason I am having trouble with it. I do 99.9% web programming and this is the first windows app i've done in years - probably the first ever in C# ......
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.