[C#] Creating a DLL to hide your C# code and then use it in your C# program

binh12A3
2 min readSep 6, 2023

1. Overview

  • A Dynamic Link Library (DLL) is a library that contains functions and codes that can be used by more than one program at a time.
  • Once we have created a DLL file, we can use it in many applications. The only thing we need to do is to add the reference/import the DLL file.
  • Both .dll and .exe are executable program modules but the difference is that we can’t execute the dll file directly.

2. Creating a .dll file

  • Create a new “Class library (.NET Framework)” project
  • Code, Build then we’ll receive an output “BinhHelper.dll” file
Source : https://gist.github.com/binh12A3/9b55f79dab96342da40fa8d606adf39d

3. Using .dll file in another project

  • Create a new “Windows Forms App (.NET Framework)” project
  • Add reference, “Browse” to “BinhHelper.dll” file
  • Code

--

--