If condition executed even on false value

This is the full script attached to the game object with only transform component as inspector

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Test : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
     
    }

    // Update is called once per frame
    void Update()
    {
        var b = false;
        Debug.Log("Outside If condition :" + b);
        if (b) ;
        {
            Debug.Log("Inside If condition :" + b); // How come this is executed ????
        }
    }
}

output

You have ; after if.

3 Likes

Thank you so much… IDE dimmed ; and I was almost stuck for more then an hour.

1 Like