Argument Modifiers: 'ref', 'out', 'params' and 'this'

Some c-sharp devs must slink through their whole skanky career, utterly ignorant about argument modifiers.

There's usually a way to avoid thinking about them: if you're willing to write a lot more code and have your existing stuff crash and get patched many more times.

The best known 'argument modifier' is probably 'ref' -- and it's purpose is pretty damn powerful. I assume you know its purpose: but just imagine you've just gone from a state of not knowing what the ref param modifier does, to a state where you know what it does. Think of all the things you couldn't do before that are now open to you. Hold that thought.

I'd say that I use 'out' possibly a little more often than I use 'ref' -- yet I wouldn't rank it quite so high on the 'mind-blowing' stakes. The 'params' argument modifier is certainly mind-blowing, if you've never used it before. It gives the language a whole big chunk of 'affordance' -- allow you to achieve, very simply, ranges of motion that are otherwise almost inachievable.

But what about the 'this' modifier.

I'd wager that 70% of the C sharp devs out there haven't yet parsed the 'this' argument modifier.

And when they do -- i hope to see the nightsky light up with the colourful spectacle of a hundred thousand minds noisily exploding under the power of extension methods.

If you're part of that sad 70%, go now and learn how to implement an extension method or ten.


I'm currently writing a book about how to build your first product. If you want to build your first product, please sign up to be notified when the book is available.

(By the way, I read every comment and often respond.)

Your comment, please?

Your Name
Your Url (optional)
Note: I may edit, reuse or delete your comment. Don't be mean.