4 years ago

Hey! More than half of Unity game development is spent on programming.

How well do you know C#? Let's check!

What will be output to the console when the Start() method is executed? Choose the answer below!

(Full code in the article)


SampleScript.cs

		
			using UnityEngine;

namespace Assets.Samples.Sample1
{
    public class SampleScript : MonoBehaviour
    {
        private void Start()
        {
            int firstValue = 0;
            for (int i = 0; i < 5; i++)
                firstValue = PostfixIncrement(firstValue);

            int secondValue = 0;
            for (int i = 0; i < 5; i++)
                secondValue = PrefixIncrement(secondValue);

            print(quot;First value = {firstValue}, second value = {secondValue}");
        }

        private int PostfixIncrement(int value)
            => value++;

        private int PrefixIncrement(int value)
            => ++value;
    }
}
		
	
  50 votes Voting finished



9 comments

Loading...

Next up

Help wanted!

Translator (any language), Animator

More information in the article

Help wanted!

Voice actor (Spanish)

More information in the article

Main menu demonstration

Interface has reached final form. Drawing icons, writing logic and supporting many languages - all this was done by me.

UI/UX design is quite an interesting experience, I'll definitely continue to learn it in my new projects

2025

Lucky Tower Ultimate is a chaotic, comedy roguelite. Escape from an incredibly dangerous, randomly generated tower in a slapstick adventure that looks like a cartoon and feels like a joke. Slashy slashy! 

Wishlist the game now: https://bit.ly/LuckyTowerUltimate

The project is in the final stages of development - game balance and testing team will begin forming very soon.

But before that, some animations need to be finished.

More information in the article

Happy #WIPWednesday! Are you working on a game? Making some art? Practicing a song? Something else? Tell us in the comments!

Help wanted!

Translator (English -> Portuguese)

More information in the article

Help wanted!

Animator

More information in the article

#LuckyTowerUltimate is OUT NOW on Steam and Nintendo Switch! It's your turn to become the Chosen One and rid the land of Evelius’s tower for good! https://store.steampowered.com/app/1700270/Lucky_Tower_Ultimate/

Introducing the translation team!

9 languages, 7 translators and a huge amount of content to translate. I'm sure it's worth it!

Links and contacts will be on the new game page that will be created soon

2025