We help IT Professionals succeed at work.

Last item in the array

Nugs
Nugs asked
on
263 Views
Last Modified: 2010-04-15
I am trying to get the last item in an array every time... The array may be any size but i know that the last item in the array is always the value i need... I am trying to do this and the code is failing:

int arySize = aryItem.Length;
in MyVariable = Convert.ToInt32(aryItem[arySize]);

How can i get the last array item every time?

Nugs
Comment
Watch Question

Sr. Software Architect
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
PHD

Commented:
Did you test the upperbound method of the array ?

Author

Commented:
realevergod: that worked, thanks..

PHD: I tried out LowerBound... Maybe i used it wrong but did not get the results i needed

Nugs
PHD

Commented:
upperbound
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.