3
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by bhagawatshinde
-1

I don't know C# but I can tell you the logic.

int a[10];

for(i=0;i<a.length;i++);

printf("Last element %d ",a[i-1]);

Votes + Comments
That is not an array list, also, 0 - 1 = -1...
0

ArrayList is an ordered collection of objects so last element must be Count-1.

ArrayList a = new ArrayList()
            {
                11,22,33,44,55,77
            };

 object last=a[a.Count - 1];

 List<int> b = new List<int>()
            {
                11,22,33,44,55,66,77
            };

 int lastele=b.Last();
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.