Home > Enterprise >  How to define a Class which is accessible in all classes in C#?
How to define a Class which is accessible in all classes in C#?

Time:01-16

Am new to C#, but have a plenty of experience of VB.net, now my issue is that there are no modules in C# and i need to define a class which is accessible in all classes and i don't know how to do it. For example I have a "classProject" and I need to make it accessible everywhere, so in vb.net , I will define it in module like below.

Module ModuleMain
Public tProject As New ClassProject
End Module

Now, I need to do same in C#. Thanks in advance.

CodePudding user response:

It sounds like you're looking for a static class. You can reference the access modifiers here: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers

CodePudding user response:

I think you need to extends your other classes to class father (ClassProject) And you can access to it with youur children classes.

CodePudding user response:

//[access modifier] - [class] - [identifier]
public class Customer
{
// Fields, properties, methods and events go here...
}

see more

  •  Tags:  
  • Related