What’s the difference between a partial method and a partial class?

Like “fixed” and “into”, “partial” is also used in two confusingly similar-yet-different ways in C#. The purpose of a partial class is to allow you to textually break up a class declaration into multiple parts, usually parts found in separate files. The motivation for this feature was machine-generated code that is to be extended by…

33

What’s the Difference, Part Four: into vs into

The keyword “into” in a query comprehension means two different things, depending on whether it follows a join or select/group. If it follows a join, it turns a join into a group join. If it follows a select or group then it introduces a query continuation. These two features are quite different, but easily confused….

8

What’s the Difference? Part Three: fixed vs. fixed

I got an email the other day that began: I have a question about fixed sized buffers in C#:  unsafe struct FixedBuffer { public fixed int buffer[100]; } Now by declaring buffer as fixed it is not movable… And my heart sank. This is one of those deeply unfortunate times when subtle choices made in the…

16

Reserved and Contextual Keywords

Many programming languages, C# included, treat certain sequences of letters as “special”. Some sequences are so special that they cannot be used as identifiers. Let’s call those the “reserved keywords” and the remaining special sequences we’ll call the “contextual keywords”. They are “contextual” because the character sequence might one meaning in a context where the…

11