Expose a Read-Only Collection in C# with AsReadOnly
Let callers read a private list without changing it, using AsReadOnly and IReadOnlyList, and why returning IEnumerable alone does not protect it.
Let callers read a private list without changing it, using AsReadOnly and IReadOnlyList, and why returning IEnumerable alone does not protect it.
Check that a string looks like an email address in C# with MailAddress.TryCreate or a simple source-generated regex, and why no regex can fully validate one.
A small, thread-safe generic cache manager in C# built on MemoryCache from Microsoft.Extensions.Caching.Memory, with expiration, GetOrCreate and size limits.
Resize an image in C# with System.Drawing at high quality, keep the aspect ratio, avoid gray edges and control JPEG quality when saving.