Professional Development – 2024 – Week 18

Image Credit: https://www.flickr.com/photos/54585499@N04/

.NET

The New Collection Access Feature of C# 13 (via Nick Chapsas)

C# 13 will have a new feature: implicit index access. Suppose you have an array (with four elements) and you want to get the last element. Your options are array[3], array[array.Length – 1], array.Last(). There’s now something like this: array[^1] with the “from end” operator. (It’s not ^0 because Microsoft copied how Python does this.) This is useful if you’re trying to initialize an array while you’re initializing a class that contains that array (i.e., object initializer expressions). This is likely a niche feature and is tied to the language version, not the runtime version.

The Only .NET Scheduler You Should Be Using! (via Nick Chapsas)

  • Hangfire is an open-source library (with paid option) to perform background processing and things like cron jobs.
  • The easiest way to host it is in a ASP.NET Core project because it provides a dashboard. The jobs are stored in a data store that you can choose (e.g., SQL Server, Postgres, SQLite, InMemory).
  • The queuing and processing are handled separately. The process checks the queue on an interval you define.
  • Caveat: What’s stored about how to execute jobs is assembly-specific, so if you end up moving/renaming things, the job may not execute.