LFInteractive Docs
  • Programming Documentation
  • C#
    • Installing Visual Studio
    • Understanding C#
      • Namespaces
      • Classes
      • Enum
      • Variables
        • Static Types
        • Primitive Types
        • Access Modifiers
        • Variables vs Properties
        • Nullable Variables
      • Getters and Setters
      • Solution vs Project
      • Struct vs Class
      • Coding Conventions
      • Tasks and Async
        • Parallel Tasks
      • Methods
      • PreProcessor Statements
    • Creating Your First Console App
      • Class Library
        • Models
          • File Model
          • Result Model
        • Controllers
          • File Controller
          • File System Controller
      • Console App
        • Nuget Packages
        • Main Method
    • Minecraft.NET
      • Minecraft.NET Library
      • Modrinth.NET Library
      • CurseForge.NET Library
      • Fabric.NET Library
    • Common Lib
      • Strings
      • Advanced Network Client
      • Advanced Timer
      • Advanced File Info
      • Configuration File
      • Application Config
      • Database File
      • Crypt Class
  • C++
    • Networking
      • Windows Socket (Client)
    • cclip
    • VCPKG
    • spdlog
      • Getting Started
      • Patterns
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. C#
  2. Creating Your First Console App

Class Library

PreviousCreating Your First Console AppNextModels

Last updated 1 year ago

Was this helpful?

Next we are going to create a class library to hold the majority of our code. This allows are code to be more reusable in the future. Even if you plan to delete this project once your done, this is still a good practice to follow.

  1. Open your solution explorer and right click your solution, the solution is the top-most item in the solution explorer.

  2. Then under the "Add" subsection, click "New Project"

  3. Now select "Class Library" from the templates list

  4. Name it "Library"

  5. Set the Framework to the same as the parent (.NET 6.0 (LTS) for this example)

  6. Click Create!

  7. Now delete the default class that is created!

Folder Structure

Now create two folders/namespaces inside the class library See: Namespaces

  • Controller

  • Model

The controller namespace is used to handle logic classes. Every class in this namespace should be named by this convension: "{Name}Controller.cs". For example if we wanted a class to handle the FileSystem we would say "FileSystemController.cs"

The model namespace is used to handle structure classes, these are classes that don't do anything but instead hold data. Every class in this namespace should be named by this convension: "{Name}Model.cs". For example if we wanted a class to hold FileData we would say "FileModel.cs"