Advertisement
TankorSmash

How to index a last item in an array

Aug 14th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1. //creates an array of strings, split along the slashes
  2. // ie {"c://", "users", "jtilson" etc}
  3. string[] an_array = @"C:\\Users\\jtilson\\Desktop\\Metrics\\Advance Directives_Metrics x3A 134308.xls".Split('\\');
  4. //uses the length of the array minus one as an index, grabbing the last string out of the index
  5. string last_item = an_array[an_array.Length - 1];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement