- Home /
How to implement custom using directives?
My Application is getting quite big and therefore I need a way to reduce the amount of code in my scripts.
I figured out that I could save a lot of space by putting certain methods (that I use in multiple scripts) in classes class
in a separate namespace namespace
. That way I want to be able to write an using directive using namespace
on top of the classes where I need those methods. Then I can just use class.method()
when I want to call that method, just like with using System
or using Event.System
.
The Problem is that I have to create an Instance of class
first. Why isn't that necessary for native using directives and how can I avoid it?
Answer by rh_galaxy · Mar 25 at 11:21 AM
If you just have helper methods in your class you can make the methods static, that way you don't have to create an instance first. But if you have more complex things it might not be the best.
Your answer
Follow this Question
Related Questions
How can I use method to return custom classes (Same Class Type),How to return classes in method 1 Answer
Class error: BCE0019: 'xxxx' is not a member of 'Object'. 0 Answers
The name '' does not exist in the current context 2 Answers
How do I save an array of all different variables? 0 Answers
Access to a variable inside a C# class 2 Answers