並べ替えのソースとして配列を使用して、インデックスでリストを並べ替えるのに問題があります。
私のクラスに5つのレコードが設定されていると仮定します
class Program
{
static void Main(string[] args)
{
int[] myInt {2,1,0,3,4}
List<Tests> myTests = new List<Tests>;
//this part doesn't work
for (int i = 0; i < 4; i++)
{
myInt[i] = myTests[i];
}
myTests.ForEach(i => Console.WriteLine("{0} {1}", i.id, i.myString));
}
}
私のクラスの定義
class Tests
{
public int iD {get; set;}
public string myString {get; set;}
public Tests (int iD, string myString)
{
this.iD = iD;
this.myString = myString
}
{
出て欲しいもの
record 2
record 1
record 0
record 3
record 4
リストに並べ替え関数を使ってみましたが、並べ替え条件として配列を使った例が見つからなかったので、ちょっと迷ってしまいました。私は提供された助けに感謝します。