public int LastNonEmptyIndex(string[] array) { int i = array.Length - 1; do { if (!string.IsNullOrEmpty(array[i])) { break; } } while (--i > -1); return i; }
string[] dinosaurs = {"Compsognathus", "Amargasaurus", "Oviraptor", "Velociraptor", "Deinonychus", "Dilophosaurus", "Gallimimus", "Triceratops" }; //Predicate<string> dinoType=null; //string lastvalue = Array.FindLast(dinosaurs, dinoType).ToString(); string lastItem = dinosaurs[dinosaurs.Length - 1];
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)