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

Handling global information

Hi,

I am using C# to develop Windows forms applications. I previously worked
with VB 6. My question involves the following scenario.

I want to create a splash screen, which on application start-up will be
displayed and at the same time load some data from a database, and do some
initialization and configuration. In VB I can have a global module where I
would declare system wide global variables which would be set during this
start-up period. How would I do this in C# given that it doesn't have global
variables.

Nov 15 '05 #1
2 2087
You can accomplish the same by create in class with static properties that
will act as global variables. Since the properties are static you don't need
an instance of the class, so you can use it like this:

Globals.MyVariable = "Testing";

Implementation:
public class Globals
{
static string _myVariable;

static public string MyVariable
{
get
{
return _myVariable;
}
set
{
_myVariable = value;
}
}
}
--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
"Marinos Christoforou" <ma*****@globalit.com.cy> wrote in message
news:OO**************@TK2MSFTNGP12.phx.gbl...
Hi,

I am using C# to develop Windows forms applications. I previously worked
with VB 6. My question involves the following scenario.

I want to create a splash screen, which on application start-up will be
displayed and at the same time load some data from a database, and do some
initialization and configuration. In VB I can have a global module where I
would declare system wide global variables which would be set during this
start-up period. How would I do this in C# given that it doesn't have global variables.

Nov 15 '05 #2
Thanks Jan,

Seems obvious now.
"Jan Tielens" <ja*@no.spam.please.leadit.be> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
You can accomplish the same by create in class with static properties that
will act as global variables. Since the properties are static you don't need an instance of the class, so you can use it like this:

Globals.MyVariable = "Testing";

Implementation:
public class Globals
{
static string _myVariable;

static public string MyVariable
{
get
{
return _myVariable;
}
set
{
_myVariable = value;
}
}
}
--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
"Marinos Christoforou" <ma*****@globalit.com.cy> wrote in message
news:OO**************@TK2MSFTNGP12.phx.gbl...
Hi,

I am using C# to develop Windows forms applications. I previously worked with VB 6. My question involves the following scenario.

I want to create a splash screen, which on application start-up will be
displayed and at the same time load some data from a database, and do some initialization and configuration. In VB I can have a global module where I would declare system wide global variables which would be set during this start-up period. How would I do this in C# given that it doesn't have

global
variables.


Nov 15 '05 #3

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

Similar topics

1
by: Subramanian Iyer.NET | last post by:
Hi, Considering the scenario for handling exceptions in Web Application where we have Presentation layer, Business layer and Data Access layer; if there any exception is occurred in DAL, which...
5
by: Frame | last post by:
I'm looking for tutorials or articles considering HTML Frames and how to handle them with Javascript. E.g. samples how Frames can exchange information, can a Frame instruct other Frame to update...
7
by: Spacen Jasset | last post by:
The main two desirable things I feel error handling should provide are these: 1) Debugging and diagnostic aid 2) User feedback One method that is used a fair amount it to 'say' that all...
13
by: tolisss | last post by:
Hi i have setup a global exception handler b4 Application.Run like Application.ThreadException += new ThreadExceptionEventHandler(GlobalExceptionProcessing.AppThreadException ); then after...
2
by: Jim Slade | last post by:
I'd like to be able to log each error that occurs in an ASP.NET application. Do I really need to have a try/catch block in every single one of my methods? Is there a way to somehow handle ALL...
3
by: Mr Newbie | last post by:
I'm testing error handling configurations and having some trouble. I created a WebForm called. ErrDefault.aspx and I am trying to use the Page error attribute to force the redirection to a custom...
8
by: jcrouse | last post by:
I am using the following code to trap errors in a sub routine: Try Executable code Catch ex As Exception Dim strInputE As String = Application.StartupPath & "\Error.txt" Dim srE As...
1
by: metsys | last post by:
We have an ASP.NET 2.0 (C#) application that is divided into multiple layers. The multiple layers come from having a web project and 2 different class library projects in the same solution. I'm...
41
by: Zytan | last post by:
Ok something simple like int.Parse(string) can throw these exceptions: ArgumentNullException, FormatException, OverflowException I don't want my program to just crash on an exception, so I must...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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
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,...
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...

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.