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
  • Fields
  • Example:

Was this helpful?

Edit on GitHub
  1. C#
  2. Creating Your First Console App
  3. Class Library
  4. Models

File Model

This will hold information on each file type

Lets create a struct in our Models namespace and name it FileModel.cs See: Struct vs Class

Fields

Now we will create five properties See: Variables vs Properties

Name
Type
Description

Extension

string

The file extension

Count

int

The number of files with the extension

Bytes

long

The total number of bytes

Characters

int

The total number of characters in each file

Encoding

System.Text.Encoding

The encoding type

See: Primitive Types

Example:

using System.Text;

namespace Library.Model;

public struct FileModel
{
    // The file extension
    public string Extension { get; set; }
    // The number of files with the extension
    public int Count { get; set; }
    // The total number of bytes
    public long Bytes { get; set; }
    // The total number of characters in each file
    public int Characters { get; set; }
    // The encoding type
    public Encoding Encoding { get; set; }
}
PreviousModelsNextResult Model

Last updated 1 year ago

Was this helpful?