以下の内容はhttps://baba-s.hatenablog.com/entry/2021/08/13/090000より取得しました。


【C#】値をスワップする関数を自作する

ソースコード

public static class GenericUtils
{
    public static void Swap<T>( ref T a, ref T b )
    {
        var tmp = a;
        a = b;
        b = tmp;
    }
}

使用例

using UnityEngine;

public class Example : MonoBehaviour
{
    private void Awake()
    {
        int a = 1;
        int b = 2;

        GenericUtils.Swap( ref a, ref b );

        Debug.Log( a );
        Debug.Log( b );
    }
}



以上の内容はhttps://baba-s.hatenablog.com/entry/2021/08/13/090000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

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