Result Model

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

Fields

Now we will create four properties See: Variables vs Properties

Name
Type
Description

Count

int

The number of results

NumberOfFiles

int

The total number of files processed

Duration

TimeSpan

The time it took to compile results

Items

FileModel[]

The file extensions processed

See: Primitive Types

Example:

namespace Library.Model;

public struct ResultModel
{
    // The number of results
    public int Count { get; set; }

    // The total number of files processed
    public int NumberOfFiles { get; set; }

    // The time it took to compile results
    public TimeSpan Duration { get; set; }

    // The file extensions processed
    public FileModel[] Items { get; set; }
}

ToString

Add ToString() Method

public override string ToString()
{
    return JsonConvert.SerializeObject(this, Formatting.Indented);
}

Last updated

Was this helpful?