var NNN = new int[4] { 11, 22, 33, 44 };
var newNNN = NNN.ToDictionary(m => m, n1 => NNN.Select((a, index) => new { a, index }).FirstOrDefault(b => b.a == n1).index);
Console.WriteLine(newNNN[22]); //1
时间: 2024-10-24 19:21:42
var NNN = new int[4] { 11, 22, 33, 44 };
var newNNN = NNN.ToDictionary(m => m, n1 => NNN.Select((a, index) => new { a, index }).FirstOrDefault(b => b.a == n1).index);
Console.WriteLine(newNNN[22]); //1