I have two constants, defined in the same static class:
public static class MyConstants {
public const string ABC = "ABC";
public const string DEF = "DEF";
}
I use them in a combined manner, elsewhere in my application:
Console.WriteLine(MyConstants.ABC + MyConstants.DEF);
I'm trying to determine if the concatenation is optimized at compile time, resulting in the assembly containing a value of ABCDEF
at some address when disassembled, or if it stays separate. I followed the instructions on this MSDN post to view the disassembly of my code in a console application and it appears that it is not stored as ABCDEF
, nor separate as ABC
, DEF
:
This post was a good read, but ultimately confused me in relation to my question (likely due to my lack of C++ knowledge). I've looked at several other posts and don't really seem to be getting anywhere near the answer.
Does C# optimize the concatenation of two constants in the compiled version of an application, any/everywhere that concatenation is used?
NOTE: The goal is to further obfuscate the full value of ABCDEF
, making it harder to find.