Sunday, March 11, 2012

Declaring a global variable

How does one go about declaring a global variable?

You don't. Not that it's impossible, but it's a thing mostly used in non object oriented architectures, and it's usually not suitable. The closest thing is to declare a static member on a class

public class SomeClass
{
public static string SomeValue="The Value";
}

which will then be accessible as SomeClass.SomeValue

|||

you can define global variables with Static keyword in C# within a class as..

Public Static String strCurruntUser

and in VB with Shared keyword as..

public Shared strCurrent as String

but better to prefer to use Session Variables instead of Global variables with Static / Shared...

hope it helps./.

|||

I'm trying to declare a global variable in Reporting Services

|||

Easiest is a parameter you default how you like.

No comments:

Post a Comment