The Pragmatic Programmer

Tulisan iseng kalo ada waktu.
See also: Other Geeks@INDC

November 2007 - Posts

VB For Loop and C# For Loop

I have a list of integer that contains four data, let says I use an array list:

            System.Collections.ArrayList arl = new System.Collections.ArrayList();

            arl.Add(1);
            arl.Add(0);
            arl.Add(1);
            arl.Add(1);
 

I want to remove all zeros from the list but I must iterate the list, so I use this algorithm to achieve it:

            for(int i = 0; i < arl.Count; i++)
            {
                if(((int)arlIdea) == 0)
                {
                    arl.RemoveAt(i);
                    i--;
                }
            }

How to do it in VB? Any one knows? 

It seems simple, but remember, nothing as simple as it seems.

Share this post: | | | |