C# guides
Every published C# guide, newest first, with practical examples you can copy into your own project.
3,965 guides across 14 topics
Topics
Popular C# guides
Most readLatest C# guides
Page 68 of 77C# Array Loops: for vs foreach and More
Learn how to iterate over C# arrays effectively. Compare for and foreach, handle multidimensional and jagged arrays, and avoid common pitfalls.
C# Array Length: Property, Pitfalls, and Performance
Learn how to use the Length property on C# arrays, handle multi-dimensional and jagged arrays, avoid common mistakes, and understand performance implications.
C# Modify Array Values: Direct Assignment and Alternatives
Learn how to modify array values in C# using direct indexing, Array.Copy, Span<T>, and List<T>, including performance tradeoffs and common pitfalls.
C# Array Initialization: Syntax and Common Patterns
C# arrays store a fixed number of elements. Learn common initialization forms, default values, rectangular and jagged arrays, C# 12 collection expressions, and how to choose between arrays and List<T>.
C# Array Declaration: Syntax and Usage
Understand C# array declaration syntax, initialization patterns, and the tradeoffs between arrays and List.
C# foreach with index: getting the current iteration index
Learn how to get the current index inside a C# foreach loop using a counter, LINQ Select, or a for loop, and understand the tradeoffs.
C# Infinite Loop: Causes, Detection, and Prevention
Understand how infinite loops occur in C#, how to break out of them, how to debug them, and how to prevent them in production code.
C# Exit Loop: Using break, return, and goto
c# exit loop: Learn how to exit loops in C# using break, return, and goto. Understand when each statement is appropriate and how they affect control flow.
C# break vs continue: When to Exit a Loop or Skip an Iteration
c# break vs continue: Learn the difference between break and continue in C# loops, with practical examples and guidance on when to use each.
Using the C# Continue Statement in Loops
How the C# continue statement skips the rest of an iteration in for, foreach, while and do-while loops, with nested-loop examples and common mistakes.