Where is Java’s Array indexOf?

There are a couple of ways to accomplish this using the Arrays utility class. If the array is not sorted and is not an array of primitives: java.util.Arrays.asList(theArray).indexOf(o) If the array is primitives and not sorted, one should use a solution offered by one of the other answers such as Kerem Baydoğan’s, Andrew McKinlay’s or … Read more

Why doesn’t indexOf work on an array IE8?

Versions of IE before IE9 don’t have an .indexOf() function for Array, to define the exact spec version, run this before trying to use it: if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(elt /*, from*/) { var len = this.length >>> 0; var from = Number(arguments[1]) || 0; from = (from < 0) ? Math.ceil(from) : Math.floor(from); … Read more

Find index of returned list result C#

As the error states, it cannot convert from ‘System.Collections.Generic.List’ to ‘string’. However I never knew the function SingleOrDefult() existed. All credit to @maccettura even though he didn’t know what I was trying to do! xD Code change below for the answer: List<string> listFrom = new List<string>(); //Contains a list of strings List<string> listTo = new … Read more