以下の内容はhttps://mochimoffu.hateblo.jp/entry/2020/05/28/003000より取得しました。


C#の話~複数の戻り値を受け取る方法~

Luaだと複数戻り値を受け取り方法はあるのだが、C#でも複数戻り値を受け取る方法無いのかなと調べたら、
新しめのC#であればTupleValueという物が使えるようなので、備忘録

using UnityEngine;

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

    private void Test()
    {
        var (resInt, resString, resGameObject) = MultiValueReturnFunction();

        Debug.Log(resInt);          // 10
        Debug.Log(resString);       // あいうえお
        Debug.Log(resGameObject);   // スクリプトアタッチしているオブジェクトの情報
    }

    private (int, string, GameObject) MultiValueReturnFunction()
    {
        int resInt = 10;
        string resString = "あいうえお";
        GameObject resGameObject = this.gameObject;

        return (resInt, resString, resGameObject);
    }

}



以上の内容はhttps://mochimoffu.hateblo.jp/entry/2020/05/28/003000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14