As already shared you cannot stop entirely, but you can
and make it harder to reverse engineer.
Quote:Dotfuscator can obfuscate your .NET assemblies to hinder reverse-engineering, while maintaining original application behavior.
Reference: Dotfuscator Community - Visual Studio | Microsoft Docs
There are more such tools that provide different levels of security. You will have to find another if above does not suits you.