
Explore peculiar cases of mutable structures in C#, highlighting how read-only fields, arrays, and using blocks can yield surprising behavior, and distinguish structures from classes through concrete code examples.
Explore class versus structure, focusing on copying by value versus by reference, immutability in value types, and examples of mutable versus immutable designs.
Explore how lists and arrays of structure objects differ when mutated, revealing that arrays can modify elements through a special Alma optimization, while lists copy elements.
Explore how mutable structs and using blocks interact with IDisposable, highlighting boxing pitfalls, disposal behavior, and why mutable structs should be avoided.
Explore generics and arrays in C#, and how the compiler chooses between generic and specialized methods. Grasp variance, contravariance, and Liskov substitution principle with generics constraints, puzzles for metaprogrammers.
Examine how the C# compiler resolves a specialized run method for A versus a generic one for B, including dynamic variants and the performance benefits of specialization.
Explore how generics constraints on extension methods influence method resolution, showing why the compiler selects the generic bar method over non-generic ones and how to force a specific overload.
Examine how covariance in C# arrays causes a runtime mismatch when scaling 3D points with a 2D point method. Learn alternatives using enumerable-based scaling and the Liskov substitution principle.
Explore the Liskov substitution principle within solid, showing subtypes substitutable for base types and avoiding contract violations and covariance/contravariance issues.
Analyze a classic LSP violation using rectangle and square, and show how an IShape interface enables correct area calculation while decoupling data and behavior.
Learn to properly compare floating point numbers in C#, and discover overflow behavior, explicit checks, rounding quirks, and the decimal versus money distinction.
Understand floating point numbers, their base two representation, how rounding errors affect 0.1 and 0.2 versus 0.3, and why use tolerance for comparisons instead of strict equality.
Explore how arithmetic overflow affects int, decimal, and double by adding one to their max values, revealing wrap to min, decimal overflow exceptions, and double infinity.
Discover how to enforce arithmetic overflow checks in C# with global project settings, checked sections, and unchecked, and why using int is preferred over unsigned types.
Compare midpoint rounding modes in C#: away from zero and to even, showing how banker's rounding defaults to to even and how it preserves data in mean calculations.
integers are stored in base two and represented precisely in memory using short, long, and 32-bit values; floating point types differ in precision and performance.
Explore how to modify existing collections, understand deferred execution in link and Linq expressions, handle closures in foreach loops, and convert lists from one type to another.
Learn safe ways to alter a list in C#, avoiding foreach modifications. Use a backward for loop, RemoveAll with a predicate, or filter into a new list with Linq.
Explore how Linq expressions use deferred versus greedy execution with a list of integers and a where filter, and how removing an item before evaluation alters the end result.
Explains why converting a list of integers to doubles can fail with casts and convert method. Shows that dynamic typing via the dynamic type and the DLR enables successful conversion.
Explore pitfalls of modifying lists, including for loops, iterator changes, and converting lists; compare remove all versus duplicate collections; distinguish deferred and greedy link operators and external variable capture.
Explore method overloading, constructor overloading, and compiler resolution; identify pitfalls like method hiding in abstract classes, and decide when to use a property over a method with optional parameters.
The compiler resolves method overloads using the most derived type, calling an overloaded derived method even if a better match exists. Avoid overloads in inheritance; prefer overriding or different names.
Explore method overriding and hiding in C#, comparing a base and derived class using the new keyword, and learn why virtual overrides behave reliably.
Learn three key guidelines for abstract classes in C#, including never exposing public constructors, keeping minimal base logic, and avoiding dangerous virtual calls during initialization.
Explore date and time pitfalls, including leap year edge cases, February 29, and clock drift, with real-world bugs like the Zune firmware issue and bank terminal outages.
Explore how computers track time with ticks of 100 nanoseconds, UTC as the civil time standard, and how time zones and date time kind options (unspecified, local, UTC) interact.
Explore date and time puzzles in C# and learn how the proleptic Gregorian calendar affects validity, why leap seconds matter, and why rely on the IANA time zone database.
Explore how date time roundtrip works in c#, focusing on Moscow time zone rules, utc vs local perspective, and the limitations of date time compared to date time offset.
Explains calculating age in C# with date time, addressing leap years, time zones, and 29 February corner cases; presents a correct approach and suggests using a time library.
Explore the pitfalls of standard date time types, revealing how local perspectives and offsets hide time zone details, DST ambiguities, and arithmetic pitfalls that scheduling tools like Quartz address.
Explore common C# interview topics through puzzles and questions, including abstract classes versus interfaces, IDisposable, and encapsulation. Preview interning, constant versus readonly, lock versus monitor, rethrow, and stringbuilder versus string.
Explore the semantic and mechanical differences between abstract classes and interfaces: abstract classes offer default implementations and reusable logic, while interfaces provide signatures and extendability as external contracts.
Learn when to implement the dispose pattern in C#, distinguish managed and unmanaged resources, and use IDisposable with or without finalizers to prevent memory leaks.
Explore encapsulation and information hiding in C# to protect invariants and design clear apis, while applying the command query separation principle and avoiding ambiguous return types.
Explore how the CLR handles strings through interning to reduce allocations, using a hash table to share literals, with the Intern and IsInterned methods and manual interning for performance.
Learn the difference between const and readonly in C#, where const values are resolved at compile time and readonly at runtime, influencing maintenance, compatibility, and flexibility.
Examine the difference between lock and monitor for synchronization in C#, discuss a subtle vulnerability, and learn safe use with Monitor.Enter overload.
Learn how to rethrow exceptions in C# while preserving the original stack trace. See how to use the throw keyword to reveal the initial error source and avoid hiding it.
Compare string and StringBuilder performance: strings are immutable and create instances on change, while StringBuilder is mutable and avoids allocations; use strings for few changes, StringBuilder for many.
Explore the semantic differences between abstract classes and interfaces, implement the dispose pattern early, and examine encapsulation: invariants protection and information hiding.
Explore how nullable arithmetic creates surprising comparison results between one and null, while the default comparator enforces a total order with null at the bottom.
Explore a puzzle about out parameters, showing they are passed by reference and act like ref parameters; if X and Y are equal, they end equal, so the result depends.
Join the bonus lecture and explore exclusive discounts, reviews, mailing list updates, blog posts, and the creator's Patreon for ongoing educational support.
This is an advanced C# course.
Build a solid foundation in C# learning odd cases related to how the language is designed
This course contains mostly practical puzzles learning which you get a better C# developer. You can find out on the Internet tons of impractical puzzles which don’t make you a better C# developer. This is not about this course. Yes, of course, even impractical puzzles sometimes are helpful especially if you’re preparing for a C# interview. However, I bet on puzzles which teach you the thing you absolutely need to understand. Indeed, this course deepens your understanding of C#. Apart from that, you’ll learn some very important things like the problem of types substitution. You’ll learn about the fundamental problems related to processing date and time values. Believe me, you’ll be astonished!
This course is built in a manner of a game. I’ll show you code examples in Visual Studio and ask to answer the question related to that code example. You’ll have some time to come up with your own answer and after that we continue. Puzzles, gotchas and cautionary tales are presented here to frighten and inspire you! Regardless of your current skills, you’ll remember things you’ve forgotten, learn things you didn’t know and become a more robust programmer.
So, this course is "must see" for anyone who wants to improve his knowledge of C#.
Here is my Teaching Approach
No fluff, no ranting, no beating the air. I respect your time. The course material is succinct, yet comprehensive. All important concepts are covered. Particularly important topics are covered in-depth.
Take this course, and you will be satisfied.
Content and Overview
This course is aimed at all kind of developers. It provides solid theoretical base reinforced by the practical material.
In short, this advanced C# course covers the following topics:
The evilness of the mutable structures. You’ll see several examples when mutable structures demonstrate the unexpected behavior.
Generics and arrays including specializations, constraints on generics, variance and covariance, Liskov substitution principle and more
The pitfalls in arithmetic: how floating-point numbers are implemented, how to compare them, how arithmetic overflow behaves with different types, how rounding works, the difference between decimal and money
Collections and LINQ: how to alter an existing list, the deferred execution of LINQ expressions, the peculiarities of closures within for and foreach loops, list conversion
Methods and Overloading: overloading base methods, method hiding, when to prefer property over method; the reasons on why to avoid optional parameters, implementing abstract classes
Date and Time puzzles: concepts related to dates and times including how a computer stores time, UTC and GMT, time zones, global and local perspectives; time-zone related puzzles, roundtrips, arithmetic on dates, how to calculate the age.
FAQ at C# Interviews: abstract classes versus interfaces, how to implement the Dispose pattern, what is the difference between encapsulation and information hiding, encapsulation in practice, strings interning, constant versus read-only fields, lock versus monitor, how to rethrow exceptions, when to use StringBuilder instead of string
And yet a short section of miscellaneous puzzles Enroll and start an exciting journey learning C# puzzles!