Code behind project and I need to declare a global veriable where do I do this since there is no .h

  • Thread starter Thread starter Bryan G
  • Start date Start date
B

Bryan G

Code behind project and I need to declare a global veriable where do I do
this since there is no .h file
 
Bryan said:
Code behind project and I need to declare a global veriable where do I do
this since there is no .h file

First things first, this isn't C. Second thing, this is an
object-oriented framework (.NET, of which C# is a language), so there is
no such thing as a 'global variable'.

What are you trying to accomplish specifically? There is a better way
besides using global variables.

-c
 
Hi,

I assume you mean a Web Application, if so you can keep a reference in
either Application or Session.

Cheers,
 
Bryan:

Static members (static properties in your case) may help you.

//something like this:
class Globals{
//static fields
private static int _userId;

//static property
public static int UserId{
get {return _userId;}
set {_userId = value;}
}
}

LC
 
Hi,

In ASP.NET static properties maintain their values between clients request,
and so work like Application variables.

LC
 
Back
Top