C# と JS 構文の違い

確認済のバージョン: 4

-

難易度: 初級

Unity の C# と Javascript の構文の基本的な違いを学びます。

C# と JS 構文の違い

初級 Scripting

ExampleSyntax

Code snippet

using UnityEngine;
using System.Collections;

public class ExampleSyntax : MonoBehaviour
{
    int myInt = 5;
    
    int MyFunction (int number)
    {
        int ret = myInt * number;
        return ret;
    }
}
#pragma strict

var myInt : int = 5;

function MyFunction (number : int) : int
{
    var ret = myInt * number;
    return ret;
}
import UnityEngine
import System.Collections


public class ExampleSyntax(MonoBehaviour):

    private myInt = 5

    
    private def MyFunction(number as int) as int:
        ret as int = (myInt * number)
        return ret