3 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

After 3.5+ years, I changed the logo. I liked the old one quite well, but I decided to redesign it because of the upcoming change in my direction in game development.

What do I mean?

You'll find out soon.

Help wanted!

Translator (English -> Hindi)

More information in the article

Help wanted!

Translator (any language), Animator

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!

Animator

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!

Voice actor (Spanish)

More information in the article

Our first post is a gif because we are BRAVE It's not moving in the preview but here we goooooo

Preparations for the release are in full swing!

A new page will be created for the new version of the game. I have already created a description for it

2025