Global variables declaration

R

RP

In VB we used to add a module that contained public variables,
procedures and functions. Where to declare global variables and
functions in C# so that they are accessible everywhere.
 
N

Nicholas Paldino [.NET/C# MVP]

The equivalent of doing this in C# is to make the methods and variables
static.
 
J

jpuopolo

RP:

There are no such things as "global" variables and methods in C#.
The way to handle this in C# is to declare a static class that contains
static variables and methods, e.g.,

static class MyGlobals {
public static void myFunction(int n) { }
public static _global_count = 0;
}

jpuopolo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top