gtag('config', 'UA-180278623-1'); UNITY 3D C# Temelleri Operatörler (UNARY OPERATOR) - Bilginiz Dahilinde

Ads Top

UNITY 3D C# Temelleri Operatörler (UNARY OPERATOR)

 UNARY OPERATOR:

UNARY OPERATOR:


public class HelloWorld : MonoBehaviour

{

    public int sayi1 = 18;

    public int sayi2 = 20;

    private float sonuc;

    public bool goster;

    public bool goster2;

    // ++, --

    void Start()

    {

        sayi1++;

        print(sayi1);     

    }

    Sayi1’ 1 ekler. Yani 18+1=19 olur ve konsola 19 yazdırır

        ++   Değere 1 ekler

        - -    Değerden 1 çıkarır

    // Update is called once per frame

    void Update()

    {   

    }

}

public class HelloWorld : MonoBehaviour

{

    public int sayi1 = 18;

    public int sayi2 = 20;

    private float sonuc;

    public bool goster;

    public bool goster2;

   // ++, --

    void Start()

    {

        sayi1 = sayi1 + 1;

        print(sayi1);

    }

  Diğer bir yolu sayi1 = sayi1 + 1;

    Bu durumda sayi1 değerini yine 1 arttırır ve yine ekrana 19 yazdırır.

  // Update is called once per frame

    void Update()

    {  

    }

}

 public class HelloWorld : MonoBehaviour

{

    public int sayi1 = 18;

    public int sayi2 = 20;

    private float sonuc;

    public bool goster;

    public bool goster2;

    // ++, --

    void Start()

    {

        sayi1 += 1;

        print(sayi1);      

    }

    Sayi1 += 1 yazılırsa yine aynı şekilde sayi1 değerini bir arttırır. Konsola 19 yazar

   // Update is called once per frame

    void Update()

    {  

    }

}

 

Hiç yorum yok:

Blogger tarafından desteklenmektedir.