Link to home
Start Free TrialLog in
Avatar of JezzaKashel
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
Avatar of flavo
flavo
Flag of Australia image

Hi JezzaKashel,

Something like this

public class myGlobals
{
private string sConString;

public string conString {
 get {
   return sConString;
 }
 set {
   sConString = Value;
 }
}

Idea???

Dave
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JezzaKashel
JezzaKashel

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