Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,166 questions

40,722 answers

573 users

How to reverse part of ArrayList in C#

1 Answer

0 votes
using System;
using System.Collections;
     
class Program
{
    public static void PrintArrayList(ArrayList list) { 
         foreach (var e in list) {
            Console.WriteLine(e);
        }
    } 
    static void Main() {
        ArrayList al = new ArrayList();
            
        al.Add("java");
        al.Add("c#");
        al.Add("python");
        al.Add("c");
        al.Add("php");
        al.Add("c++");
        al.Add("javascript");
        
        PrintArrayList(al);
                
        al.Reverse(2, 4); // 4 elements from index 2

        Console.WriteLine("\n\n");
        
        PrintArrayList(al);
    }
}
    
     
     
/*
run:
     
java
c#
python
c
php
c++
javascript



java
c#
c++
php
c
python
javascript
     
*/

 





answered Apr 21, 2020 by avibootz

Related questions

1 answer 67 views
67 views asked Apr 21, 2020 by avibootz
2 answers 72 views
72 views asked Jan 7, 2017 by avibootz
1 answer 85 views
...