Console.WriteLine("start:出自http://www.cnblogs.com/ahjesus); List sourceArr = new List { 99, 51, 61, 41, 8, 73, -3, 225, 3, 10, 0 }; ...
Console.WriteLine("start:出自http://www.cnblogs.com/ahjesus);
List<int> sourceArr = new List<int> { 99, 51, 61, 41, 8, 73, -3, 225, 3, 10, 0 };
int maxIndex = sourceArr.Max() * 10 + 1;
object[] replaceArr = new object[maxIndex];
sourceArr.ForEach(it => { replaceArr[it < 0 ? ~it * 10 : it * 10] = it; });
IEnumerable<object> result = replaceArr.Where(it => it != null);
foreach (var it in result) {
Console.WriteLine(it);
}