Перейти к содержимому

Mastering Structs

TechGuys

0:00 / 0:00

Mastering Structs

16 просмотров · 7 дней назад
TechGuys
11 подписчиков
16 просмотров · 7 дней назад
This C# code compiles with zero errors, zero warnings — and silently does nothing. In this chapter, we track down exactly why: struct copy semantics across assignment, parameter passing, boxing, and collection indexers, then the real trap — a readonly field silently mutating a throwaway copy instead of the real data. We fix it with the readonly method modifier, and prove with a real BenchmarkDotNet run that it's not just cleaner code — it's measurably faster too. 📌 What we cover: The readonly field trap: a method call that silently mutates nothing Why the compiler makes a defensive copy, and what it's protecting Fixing it with the readonly method modifier — benchmarked Every claim in this video is backed by real, live-run output — no hand-waved numbers. #csharp #dotnet #programming #softwareengineering #csharpperformance #dotnetinternals #benchmarkdotnet #structs #jetbrainsrider