Back To The Dev.Blog
Feb 07 2018

Programmer Tip - Optional Parameters

Let your code remember what it does for you.

February 7, 2018About 1 Minute
ArchivedWritten in 2018 and kept as it was, so a link or two may have gone stale.

Saving Re-Writing Code Since C# 4

When building your own systems, you might sometimes require a method you just made to slightly change its functionality in some cases.

It might be that you wish you could provide an extra boolean or number to that method, without breaking all you have already done.

In these cases, what you are looking for are optional parameters, something already built-in in C#:

Simple, Yet Powerful


  1. Write down your method.
  2. When declaring the parameters it should receive, make sure the parameters you want to make optional are ALL located at the end of the list.
  3. Assign a value to each of those parameters you want to make optional. (That value will be the “default”.)
  4. When calling the method, cover all non-optional parameters, and use as many optional parameters as you want.

Read The Full Tip HERE


Get More Useful Tips On The GitHub Wiki

What you just read about was ONE of several programmer tips that are available on the Programmer Tips Wiki.

So if you liked the one you just read, be sure to check it out (or star it) as it gets updated often! 😮

Read More Programmer Tips!


I love optional parameters, especially in game development. For example, I can create an instance of an object in a scene, and via optional parameters set the default position and rotation to 0, but leaving the option to specify them. It’s magic.

So I hope knowing this becomes useful to someone else.

That Is All For Today, But Like Always…

Thank you very much for reading my blog :3