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

GDCR - Juice It Or Lose It

While working in a game, ever felt like your progress is kinda bland? That it is missing something. That something might be juice, so keep an eye on this talk. Continue reading

Software Suggestion - Hootsuite

Published on April 05, 2018

Unity Tip - Built-In Primitive Sprites

Published on April 04, 2018