what are hashtags for in C#?
i've written C# for a month and have zero idea what these hashtag symbols are for. like
#define
- what does that do?16 Replies
its a preprocessor directive
Preprocessor directives - C# reference
Learn the different C# preprocessor directives that control conditional compilation, warnings, nullable analysis, and more
its basically a line that executes only when the scripts compiles, for example:
#undef DEBUG (makes DEBUG tag to false)
#if DEBUG
all the code here doesnt get compiled, its like it never existed and wont show in the decompiled dll
#endif
so you can add extra properties based on maybe the OS the executable is run on?
yep for example
another example would be a game engine version or the version of an asset you downloaded
Not run on, compiled on. Preprocessor directives are only used during compilation
when is a dotnet exe compiled then? if i run the final .exe, does any of the preprocessing directives get executed? or is that only when compiled?
or i guess, to rephrase, does running an exe "recompile" it, in some way?
or is this in the case of maybe a github repo where downloading the code and building the project yourself would invoke the PPDs
the code gets compiled when your sourcecode gets transformed into exe/dll
not at all
https://discord.com/channels/143867839282020352/1294321833587245097/1295449296585363487
so in the case of this, depending on where you build the project, you can have different changes for each different OS?
it’s raining outside
or is this in the case of maybe a github repo where downloading the code and building the project yourself would invoke the PPDs
Quoted by
<@566653183774949395> from #what are hashtags for in C#? (click here)
React with ❌ to remove this embed.
oh damn, thats handy
yes. they are not very common for a reason
basically compiling = take c# and make it binary (very very basically)
ah i see
thank you, all of you
i'll close this tomorrow morning