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#

Convert a Byte Array to an Image in C#

November 25, 2026September 2, 2014 by turgay

Load an Image from a byte array in C# without the “generic error occurred in GDI+” trap, plus the WPF BitmapImage version.

Categories C# .NET, WinForms Tags byte array to image, C#, convert byte array, convert byte array to image 3 Comments

Try, Catch and Finally in C#: Exception Handling Done Right

November 25, 2026August 22, 2014 by turgay

How try, catch and finally work in C#, with catch order, exception filters, rethrowing without losing the stack trace, and when finally does not run.

Categories C# .NET Tags C#, exception handling Leave a comment

Measure Execution Time in C# with Stopwatch

November 25, 2026August 22, 2014 by turgay

Time a block of code in C# with Stopwatch or Stopwatch.GetElapsedTime, read the result correctly, and know when to switch to BenchmarkDotNet.

Categories C# .NET Tags C#, calculate execution time, execution time, stopwatch Leave a comment

Conditional Compilation in C#: #if, #define and DEBUG

November 25, 2026July 14, 2014 by turgay

Include or exclude code at compile time in C# with #if and #define, use DEBUG and target framework symbols, and know when [Conditional] is the better tool.

Categories C# .NET Tags C#, conditional compilation Leave a comment

Read Command-Line Arguments in C#

November 25, 2026July 14, 2014 by turgay

Read command-line arguments in a C# console app through args or Environment.GetCommandLineArgs, parse simple options, and pass arguments with dotnet run.

Categories C# .NET Tags access command line arguments, C#, command line argument Leave a comment
Older posts
Newer posts
← Previous Page1 … Page3 Page4 Page5 … 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