2 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

This long way has come to an end.

Check out the article

Need an 3D animator (more details in the article)

Help wanted!

Voice actors, translators

More info in the article

Our 2024 Advent Calendar has opened! Day 28: @Silentfaith is a great Creator and comic artist who also codes fan games! Accept the quest and give them a follow to get Coins and a seasonal sticker!

Gameplay screenshot

(The game is still alive)

Happy #WIPWednesday!

Are you working on a game?

Making some art?

Practicing a song?

Something else?

Tell us in the comments!

Help wanted!

3D environment artist, 2D artist

Check out the article

Help wanted!

3D environment artist, 2D artist

More info in the article

Happy #WIPWednesday!

Are you working on a game?

Making some art?

Practicing a song?

Something else?

Tell us in the comments!

Unity has changed its policy regarding Runtime Fee: https://unity.com/pricing-updates. Major changes in the article.