Global var ?

Global var ?

Post by mensan » Wed, 28 May 2003 14:32:58



Hi does someone know a way of how i can create application global available
vars ?

Is there a place i can store global objects so i can use them in different
places ?

Greetings Andre Mens

 
 
 

Global var ?

Post by Herfried K. Wagne » Wed, 28 May 2003 16:36:17


Hello,


Quote:> Hi does someone know a way of how i can create application
> global available vars ?

> Is there a place i can store global objects so i can use them in
different
> places ?

\\\
Public Class MyGlobals
    Public Shared Foo As Bar
End Class
///

You can access the variable using "MyGlobals.Foo". Notice that this is
not a good object oriented design.

Regards,
Herfried K. Wagner
--
http://www.mvps.org/dotnet

 
 
 

Global var ?

Post by Steve » Wed, 28 May 2003 23:16:01


In VB.Net, public variables in a regular code module are
global to the entire application.  Code modules are not
available in C#.

Quote:>-----Original Message-----
>Hi does someone know a way of how i can create

application global available
Quote:>vars ?

>Is there a place i can store global objects so i can use
them in different
>places ?

>Greetings Andre Mens

>.

 
 
 

Global var ?

Post by Victo » Thu, 29 May 2003 01:42:28


Hi

OO way is using the singleton pattern

Regards



Quote:> Hi does someone know a way of how i can create application global
available
> vars ?

> Is there a place i can store global objects so i can use them in different
> places ?

> Greetings Andre Mens

 
 
 

Global var ?

Post by Jonathan Swar » Thu, 29 May 2003 05:07:02


Yes, but a code module in VB.NET is simply a public class with static
members.  Therefore, the following would work:

namespace MyApp.Shared
{
    public class Foo
    {
        // Read only property
        public static void string Bar
        {
            get { return "Some Value"; }
        }

        // Method
        public static bool IsValid(object o)
        {
            return (null != o);
        }
    }

Quote:}

That way you canm access them like
Console.WriteLine(Foo.Bar);

given reference to the MyApp.Shared namespace of course.

-Jonathan


> In VB.Net, public variables in a regular code module are
> global to the entire application.  Code modules are not
> available in C#.

 
 
 

1. Global Vars..

Hi,
I'm writing my first asp.net web service and where exactly do you dim a
global var or a constant? I have some string variables and some other custom
objects that I want to use but I can't seem to use them in other functions I
call.  It just seems odd to have to pass them into the function everytime.

Thanks,
Vicky

2. Newbie getting cable modem... a question

3. global vars

4. Does AT&T 7506 TAD 03A Pass CID to RS232 of Original Caller?

5. Is it possible to access session vars during global.asax Application_Begin_Request

6. Opening a MS Word file

7. --- How to use 'global' vars within a frame -----

8. PowerBook Duo basic questions

9. Global SqlConnection Object and Global.asax

10. Global.asa and global.asax

11. global.asa and global.asax ?

12. Global Functions in Global.asax

13. Global.asax.cs Error Could not load type 'localhost.Global'.