JezzaKashel
asked on
Global Variables
Hi
I'm quite new to C#, and wanted a bit of advice really on best practice.
I come from a vb background, and am used to having a declarations module, where I can add any global contansts, global ADO connections etc that can be used by the whole program.
I'm having some difficulty doing the same thing in C#. I've tried including a declarations class with the same namespace as every other class. Here I can put global enumerations which works well, but I can't seem to put global variables here.
Basically I just want a place to delcare my global SQL Connection. Can anyone suggest a good approach?
Thanks
Jeremy
I'm quite new to C#, and wanted a bit of advice really on best practice.
I come from a vb background, and am used to having a declarations module, where I can add any global contansts, global ADO connections etc that can be used by the whole program.
I'm having some difficulty doing the same thing in C#. I've tried including a declarations class with the same namespace as every other class. Here I can put global enumerations which works well, but I can't seem to put global variables here.
Basically I just want a place to delcare my global SQL Connection. Can anyone suggest a good approach?
Thanks
Jeremy
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all the comments.
Seem to remember static class members is the way forward, so will give it a go and see what happens
Thanks
Jeremy
Seem to remember static class members is the way forward, so will give it a go and see what happens
Thanks
Jeremy
Something like this
public class myGlobals
{
private string sConString;
public string conString {
get {
return sConString;
}
set {
sConString = Value;
}
}
Idea???
Dave