This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
using System.Collections; | |
using System.Linq; | |
public class StudyManager : MonoBehaviour { | |
[SerializeField] QuestionDB qDB; | |
private int[] indexList = new int[10]; | |
// Use this for initialization | |
void Start () { | |
//指定のカテゴリIDのリストを抽出 | |
var cList = qDB.list.FindAll(qData => qData.categoryID == SQLMethods.CerrentID()); | |
//データベースの更新 | |
SQLMethods.InsertQDB(cList); | |
//datetime昇順で並べ替え | |
var newList = cList.OrderBy(p => p.datetime); | |
//idを配列に移す | |
int i = 0; | |
foreach(var n in newList){ | |
if(i < 10){ | |
indexList[i] = n.id; | |
}else{ | |
break; | |
} | |
i++; | |
} | |
} | |
} |
14行目:FindAll
ここでは、現在選択中のカテゴリIDと一致する設問データを抽出している。カッコ内左側で任意の名前の仮引数を作り、=> の右側に条件文を書く。これが基本的なルールであり、割と気軽に使える。18行目:OrderBy
OrderByは任意のパラメータの昇順で並び替える。上記同様、カッコ内の左側が仮引数、右側が条件文。ここではDateTime型のパラメータで並び替えている。OrderByは元のListを変更せずに、並び替えた仮想のリストを返してくる。この型は
<追記>
0 件のコメント:
コメントを投稿