LINQ indexOf a particular entry
问题 I have an MVC3 C#.Net web app. I have the below string array. public static string[] HeaderNamesWbs = new[] { WBS_NUMBER, BOE_TITLE, SOW_DESCRIPTION, HARRIS_WIN_THEME, COST_BOGEY }; I want to find the Index of a given entry when in another loop. I thought the list would have an IndexOf. I can't find it. Any ideas? 回答1: Well you can use Array.IndexOf : int index = Array.IndexOf(HeaderNamesWbs, someValue); Or just declare HeaderNamesWbs as an IList<string> instead - which can still be an array