After building my first big project using C# i ran into a problem. My project file is about 7000 lines big atm and fillde with functions and other classes. This is ofcourse a little messy and to find the code that i actually need i sometimes need to scroll around quite a bit so i want to remove all the classes and functions to a different file. I know i can just add a c# class file and then access it by doing
namespace Namespace
{
class Functions
{
// Example Functions here
}
}
namespace OtherNamespace
{
class OtherClass
{
Namespace.Functions.Examplefunction
}
}
If the example function would actually exist that is. But i would like to get rid of the Namespace.Functions part as it would save me alot of typing and i use these functions often. How would i do that ? Is it even possible?
I know it is achievable in python like this
import math as *
for example, then you wouldnt have to write
math.cos(0)
but instead you can just write
cos(0)
using Namespace;
to your other code files. If you're using C# 6 or later you can useusing static Namespace.Functions;
and then you don't have to reference 'Functions' - see the docs for more - note that using static imports only accessible static members and nested types declared in the specified type