Skip to content

Instantly share code, notes, and snippets.

@todorok1
Created August 23, 2019 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todorok1/94941111dfef41aa253d55a2c9b1aab9 to your computer and use it in GitHub Desktop.
Save todorok1/94941111dfef41aa253d55a2c9b1aab9 to your computer and use it in GitHub Desktop.
ソートアルゴリズムのC#による実装例。その中で使用している配列の中身を表示するスクリプト。
using UnityEngine;
/// <Summary>
/// ソートアルゴリズム確認用のクラスのベースクラスです。
/// </Summary>
public class SortBase : MonoBehaviour {
/// <Summary>
/// 引数で渡された配列の中身をコンソールに表示します。
/// </Summary>
/// <param id="array">中身を確認したい配列</param>
protected void InspectArrayContents(int[] array){
// 結果格納用のStringBuilderを作成します。
System.Text.StringBuilder sb = new System.Text.StringBuilder();
// 出力用のテキストをアペンドします。
sb.Append($"配列の大きさは{array.Length}、中身は :");
foreach(int i in array){
// 配列の中身をアペンドします。
sb.Append(" ").Append(i).Append(",");
}
// 最後のカンマを削除します。
sb.Remove(sb.Length - 1, 1);
// コンソールに出力します。
Debug.Log(sb.ToString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment