Programmer Tip – Optional Parameters

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#:


  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.

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! 😮


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


Are You A Game Developer?

Hello! Glad to see other fellow indie devs around here 🙂

Just wanted to extend you an invitation to subscribe to the GAME DEVELOPER newsletter for FREE.

Don’t worry, you will ONLY receive notifications on game development content, which include helpful game development tutorials, tips and tricks, and updated on new FREE dev tools and programming tips directly on your inbox.

Leave a comment

Website Powered by WordPress.com.

Up ↑