หมายเหตุ: โพสต์นี้มีรายละเอียดมากขึ้นดังนั้นจึงไม่อยู่ในหัวข้อนี้ฉันต้องขออภัย
ที่บอกว่าเพื่อนของฉันอ่านและเชื่อว่ามันมีค่า 'ที่ไหนสักแห่ง' กระทู้นี้ไม่ใช่สถานที่ ฉันขอขอบคุณสำหรับความคิดเห็นของคุณเกี่ยวกับสถานที่ที่ควรไป (ฉันยังใหม่กับไซต์นี้)
อย่างไรก็ตามนี่คือเวอร์ชัน C # ใน. NET 3.5 ซึ่งน่าทึ่งมากที่ทำงานกับคอลเลกชันทุกประเภทโดยใช้ความหมายที่กำหนด นี่เป็นการวัดค่าเริ่มต้น (ใช้ซ้ำ!) ไม่ใช่ประสิทธิภาพหรือการลดรอบของ CPU ในสถานการณ์ dev ที่พบบ่อยที่สุดแม้ว่าจะไม่เคยเป็นสิ่งที่เกิดขึ้นในโลกแห่งความเป็นจริง (การเพิ่มประสิทธิภาพก่อนกำหนด)
*** วิธีการขยายที่ทำงานกับประเภทคอลเลกชันใด ๆ และดำเนินการกับผู้แทนการดำเนินการที่คาดหวังว่าค่าประเภทเดียวทั้งหมดจะดำเนินการกับแต่ละรายการในทางกลับกัน **
ต้องการ 3.5:
public static void PerformOverReversed<T>(this IEnumerable<T> sequenceToReverse, Action<T> doForEachReversed)
      {
          foreach (var contextItem in sequenceToReverse.Reverse())
              doForEachReversed(contextItem);
      }
NET เวอร์ชันเก่ากว่าหรือคุณต้องการทำความเข้าใจ Linq internals ให้ดีขึ้นหรือไม่? อ่านต่อ .. หรือเปล่า ..
ASSUMPTION: ในระบบชนิด. NET ประเภท Array จะสืบทอดมาจากอินเทอร์เฟซ IEnumerable (ไม่ใช่ IE ทั่วไปที่สามารถคำนวณได้เฉพาะ IEnumerable)
นี่คือสิ่งที่คุณต้องทำซ้ำตั้งแต่ต้นจนจบอย่างไรก็ตามคุณต้องการไปในทิศทางตรงกันข้าม เนื่องจาก IEnumerable ทำงานบน Array ของประเภท 'object' ทุกประเภทจึงถูกต้อง
การวัดผลที่สำคัญ: เราถือว่าหากคุณสามารถประมวลผลลำดับใด ๆ ในลำดับย้อนกลับที่ 'ดีกว่า' จากนั้นจะสามารถทำได้เฉพาะกับจำนวนเต็มเท่านั้น 
โซลูชันกสำหรับ. NET CLR 2.0-3.0:
คำอธิบาย: เราจะยอมรับอินสแตนซ์ที่นำไปใช้งานได้ของ IE โดยมีคำสั่งว่าอินสแตนซ์แต่ละอินสแตนซ์นั้นมีประเภทเดียวกัน ดังนั้นหากเราได้รับอาร์เรย์อาร์เรย์ทั้งหมดจะมีอินสแตนซ์ประเภท X หากอินสแตนซ์อื่น ๆ เป็นประเภท! = X จะมีการยกเว้น:
บริการเดี่ยว:
คลาสสาธารณะ ReverserService {private ReverserService () {}
    /// <summary>
    /// Most importantly uses yield command for efficiency
    /// </summary>
    /// <param name="enumerableInstance"></param>
    /// <returns></returns>
    public static IEnumerable ToReveresed(IEnumerable enumerableInstance)
    {
        if (enumerableInstance == null)
        {
            throw new ArgumentNullException("enumerableInstance");
        }
        // First we need to move forwarad and create a temp
        // copy of a type that allows us to move backwards
        // We can use ArrayList for this as the concrete
        // type
        IList reversedEnumerable = new ArrayList();
        IEnumerator tempEnumerator = enumerableInstance.GetEnumerator();
        while (tempEnumerator.MoveNext())
        {
            reversedEnumerable.Add(tempEnumerator.Current);
        }
        // Now we do the standard reverse over this using yield to return
        // the result
        // NOTE: This is an immutable result by design. That is 
        // a design goal for this simple question as well as most other set related 
        // requirements, which is why Linq results are immutable for example
        // In fact this is foundational code to understand Linq
        for (var i = reversedEnumerable.Count - 1; i >= 0; i--)
        {
            yield return reversedEnumerable[i];
        }
    }
}
public static class ExtensionMethods
{
      public static IEnumerable ToReveresed(this IEnumerable enumerableInstance)
      {
          return ReverserService.ToReveresed(enumerableInstance);
      }
 }
[TestFixture] คลาสสาธารณะ Testing123 {
    /// <summary>
    /// .NET 1.1 CLR
    /// </summary>
    [Test]
    public void Tester_fornet_1_dot_1()
    {
        const int initialSize = 1000;
        // Create the baseline data
        int[] myArray = new int[initialSize];
        for (var i = 0; i < initialSize; i++)
        {
            myArray[i] = i + 1;
        }
        IEnumerable _revered = ReverserService.ToReveresed(myArray);
        Assert.IsTrue(TestAndGetResult(_revered).Equals(1000));
    }
    [Test]
    public void tester_why_this_is_good()
    {
        ArrayList names = new ArrayList();
        names.Add("Jim");
        names.Add("Bob");
        names.Add("Eric");
        names.Add("Sam");
        IEnumerable _revered = ReverserService.ToReveresed(names);
        Assert.IsTrue(TestAndGetResult(_revered).Equals("Sam"));
    }
    [Test]
    public void tester_extension_method()
  {
        // Extension Methods No Linq (Linq does this for you as I will show)
        var enumerableOfInt = Enumerable.Range(1, 1000);
        // Use Extension Method - which simply wraps older clr code
        IEnumerable _revered = enumerableOfInt.ToReveresed();
        Assert.IsTrue(TestAndGetResult(_revered).Equals(1000));
    }
    [Test]
    public void tester_linq_3_dot_5_clr()
    {
        // Extension Methods No Linq (Linq does this for you as I will show)
        IEnumerable enumerableOfInt = Enumerable.Range(1, 1000);
        // Reverse is Linq (which is are extension methods off IEnumerable<T>
        // Note you must case IEnumerable (non generic) using OfType or Cast
        IEnumerable _revered = enumerableOfInt.Cast<int>().Reverse();
        Assert.IsTrue(TestAndGetResult(_revered).Equals(1000));
    }
    [Test]
    public void tester_final_and_recommended_colution()
    {
        var enumerableOfInt = Enumerable.Range(1, 1000);
        enumerableOfInt.PerformOverReversed(i => Debug.WriteLine(i));
    }
    private static object TestAndGetResult(IEnumerable enumerableIn)
    {
      //  IEnumerable x = ReverserService.ToReveresed(names);
        Assert.IsTrue(enumerableIn != null);
        IEnumerator _test = enumerableIn.GetEnumerator();
        // Move to first
        Assert.IsTrue(_test.MoveNext());
        return _test.Current;
    }
}