Reusability

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi,

I need to create some code that is always available, independently from where I am in the code (constants, global methods, etc.). I know that in VB6 one can create a module, which contains constants, global methods, etc.

What is the equivalent in C# / OOP?

Thanks.
Mike
 
Mike said:
Hi,

I need to create some code that is always available, independently from
where I am in the code (constants, global methods, etc.). I know that in
VB6 one can create a module, which contains constants, global methods,
etc.

What is the equivalent in C# / OOP?

Thanks.
Mike

Just add your own class or classes and add properties and methods to them.
 
Hi,

Have your global members (constants, methods, etc) as public/static in a class (say, Global) of your app. Then use them as Global.<member> from other places.

HTH.


Hi,

I need to create some code that is always available, independently from where I am in the code (constants, global methods, etc.). I know that in VB6 one can create a module, which contains constants, global methods, etc.

What is the equivalent in C# / OOP?

Thanks.
Mike
 
Thanks!


Hi,

Have your global members (constants, methods, etc) as public/static in a class (say, Global) of your app. Then use them as Global.<member> from other places.

HTH.


Hi,

I need to create some code that is always available, independently from where I am in the code (constants, global methods, etc.). I know that in VB6 one can create a module, which contains constants, global methods, etc.

What is the equivalent in C# / OOP?

Thanks.
Mike
 
You can add a class with static properties and static methods.

i.e.

class Globals
{
public const int MYVALUE = 3;

public static void GlobalHelperMethod()
{
// ...
}
}
 
Back
Top