Skip to content

C# Examples

  • Home
  • About C#
    • C# Interview Questions and Answers for .NET Developers
    • Learn C#: A Practical Path Through the Examples
  • All Posts
  • Bootstrap 5 Examples
  • Contact

C#

Expose a Read-Only Collection in C# with AsReadOnly

November 25, 2026June 24, 2014 by turgay

Let callers read a private list without changing it, using AsReadOnly and IReadOnlyList, and why returning IEnumerable alone does not protect it.

Categories C# .NET Tags C#, read only collection, readonly wrapper collection Leave a comment

Email Validation in C#: Regex, MailAddress and Their Limits

November 25, 2026June 23, 2014 by turgay

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.

Categories C# .NET Tags C#, email validation, regular expression Leave a comment

Disable or Hide the Close Button (X) on a Windows Form in C#

November 25, 2026June 23, 2014 by turgay

Gray out or remove the close button of a WinForms window with CreateParams or ControlBox, and stop the form from closing anyway with FormClosing.

Categories C# .NET, WinForms Tags C#, disable close button, hide close button 6 Comments

A Generic Cache Manager in C# with MemoryCache

November 25, 2026June 22, 2014 by turgay

A small, thread-safe generic cache manager in C# built on MemoryCache from Microsoft.Extensions.Caching.Memory, with expiration, GetOrCreate and size limits.

Categories C# .NET, Caching Tags C#, caching, generic cache manager 2 Comments

Resize a Bitmap in C# with Good Quality and Correct Proportions

November 25, 2026June 22, 2014 by turgay

Resize an image in C# with System.Drawing at high quality, keep the aspect ratio, avoid gray edges and control JPEG quality when saving.

Categories C# .NET Tags C#, draw image, resize bitmap 2 Comments
Older posts
Newer posts
← Previous Page1 … Page9 Page10 Page11 … Page16 Next →

Categories

Recent Posts

  • Select XML Nodes by Name or Attribute Value in C#
  • Binary Search Tree in C#: Add, Find, Remove and Traversals
  • Select, Insert, Update and Delete Data in an Access File with C#
  • C# Collections: Which One to Use and When
  • C# ArrayList vs Generic List: Examples and When to Use Each
  • About
  • Privacy Policy
  • Contact
© 2026 C# Examples