当前位置: 首页>>代码示例>>C#>>正文


C# List.IndexOf方法代码示例

本文整理汇总了C#中List.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# List.IndexOf方法的具体用法?C# List.IndexOf怎么用?C# List.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在List的用法示例。


在下文中一共展示了List.IndexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ModifLikeProduit

 public int ModifLikeProduit(List<string> aData)
 {
     DataSet DsJson = new DataSet();
     MyCo NewCo = new MyCo();
     NewCo.UpdateLikeProduit(aData.IndexOf(aData.Last()).ToString(),aData.Last(),ref DsJson);
     return aData.IndexOf(aData.Last());
 }
开发者ID:pachyderme,项目名称:FourneeDurtaloise,代码行数:7,代码来源:MenuService.asmx.cs

示例2: Jump

 public static long Jump(Dictionary<int, List<int>> cluspos, long currentpos, List<int> peaks, int[] peakclus, ref int nextvalue, ref int currentposs)
 {
     long startpos = currentpos / 2;
     int pos = (int)startpos / 512;
     if (nextvalue < peaks[currentposs])
         nextvalue = peaks[currentposs];
     if(nextvalue - pos > 0)
     {
         if(nextvalue - pos < 50)//pretty close
         {
             pos = nextvalue;
         }
     }
     else
     {
         currentposs++;
     }
     int index = peaks.IndexOf(pos);
     
     if (index != -1)
     {
         index = peakclus[index];
         Random r = new Random();
         if (r.Next(0, 100) > 25)//25% jump
         {
             int random = r.Next(0, cluspos[index].Count);
             int loc = cluspos[index][random];
             currentposs = peaks.IndexOf(loc);
             return (long)(loc * 512 * 2);
         }
     }
     return currentpos;
 }
开发者ID:jinyangnet,项目名称:AudioMix,代码行数:33,代码来源:MixerControls.cs

示例3: GetScrapers

        public static List<Scraper> GetScrapers(bool allowIgnored = false)
        {
            loadScrapers();

            List<string> scraperPriorities = new List<string>(EmulatorsCore.Options.ReadOption(o => o.ScraperPriorities).Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
            List<string> ignoredScraperIds = new List<string>();
            if (!allowIgnored)
            {
                ignoredScraperIds.AddRange(EmulatorsCore.Options.ReadOption(o => o.IgnoredScrapers).Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
            }

            List<Scraper> scrapers = new List<Scraper>();
            foreach (Scraper scraper in allScrapers)
            {
                if (allowIgnored || !ignoredScraperIds.Contains(scraper.IdString))
                {
                    if (!scraperPriorities.Contains(scraper.IdString))
                        scraperPriorities.Add(scraper.IdString);
                    scrapers.Add(scraper);
                }
            }

            scrapers.Sort((Scraper s, Scraper t) =>
            {
                return scraperPriorities.IndexOf(s.IdString).CompareTo(scraperPriorities.IndexOf(t.IdString));
            });
            return scrapers;
        }
开发者ID:ministerkrister,项目名称:Emulators,代码行数:28,代码来源:ScraperProvider.cs

示例4: IsValid

        public bool IsValid(string s)
        {
            List<char> lefts = new List<char>() { '(', '[', '{' };
            List<char> rights = new List<char>() { ')', ']', '}' };

            Stack<char> charStack = new Stack<char>();
            foreach (char c in s)
            {

                if (lefts.IndexOf(c) > -1)
                {
                    charStack.Push(c);
                }
                else
                {
                    if (charStack.Count == 0)
                    {
                        return false;
                    }
                    char pop = charStack.Pop();
                    if (lefts.IndexOf(pop) == rights.IndexOf(c))
                    {
                        continue;
                    }
                    return false;
                }
            }
            if (charStack.Count != 0) return false;

            return true;
        }
开发者ID:YouenZeng,项目名称:LeetCode,代码行数:31,代码来源:IsValidSln.cs

示例5: AssignWidthToPoints

    public List<float> AssignWidthToPoints(List<Vertex> path, float minWidth)
    {
        List<float> sumOfPointNeighb = new List<float>();
        float totalSum = 0;
        float maxSum = 0;
        foreach (Vertex v in path)
        {
            sumOfPointNeighb.Add(ftm.GetSumFromNeighbourhood(v.x, v.z, 2 * (int)minWidth));
            totalSum += sumOfPointNeighb[path.IndexOf(v)];
            if(sumOfPointNeighb[path.IndexOf(v)] > maxSum){
                maxSum = sumOfPointNeighb[path.IndexOf(v)];
            }
        }
        float averageSum = totalSum / sumOfPointNeighb.Count;

        List<float> finalWidthValues = new List<float>();
        //Debug.Log("-------------");
        foreach (float f in sumOfPointNeighb)
        {
            float value = minWidth + minWidth/2 * (maxSum - f) / maxSum;
            finalWidthValues.Add(value);
            //Debug.Log(value);
            //finalWidthValues.Add(minWidth);
        }

        return finalWidthValues;
    }
开发者ID:ja003,项目名称:Fractal-Nature,代码行数:27,代码来源:FunctionRiverDigger.cs

示例6: Main

    public static void Main()
    {
        List <int> ll = new List<int>();
        string t1;
        int idx1;
        int idx2;
        int ent1;
        int ent2;

        for(int i = 1; i <= 10; i++) {
            ll.Add(i);
        }
        foreach(int i in ll)
            Console.Write("{0} ", i);
        Console.WriteLine();
        while(true) {
            t1 = Console.ReadLine();
            if(t1 == "-999")
                break;
            string[] t2 = t1.Split(' ');
            ent1 = Convert.ToInt32(t2[0]);
            ent2 = Convert.ToInt32(t2[1]);
            idx1 = ll.IndexOf(ent1);
            idx2 = ll.IndexOf(ent2);
            ll.RemoveAt(idx1);
            ll.Insert(idx1, ent2);
            ll.RemoveAt(idx2);
            ll.Insert(idx2, ent1);
            foreach(int i in ll)
                Console.Write("{0} ", i);
            Console.WriteLine();
        }
    }
开发者ID:unitimes,项目名称:pg_practice,代码行数:33,代码来源:Lab3.cs

示例7: Animate

        //Plays an animation from a given list of Texture2D's
        public void Animate(List<Texture2D> textures, float time, float animationRate)
        {
            //Keep track of the elapsed time
            if (animationTime == null)
            {
                animationTime = time;
            }
            else
            {
                animationTime += time;
            }

            //The given animation rate determines when we switch to the next texture in the list
            if (animationTime > animationRate / textures.Count)
            {
                //Switch to the next texture in the list, or the first texture if we're at the end.
                if (textures.IndexOf(texture) < textures.Count - 1)
                {
                    texture = textures[textures.IndexOf(texture) + 1];
                }
                else
                {
                    texture = textures[0];
                }

                //Reset the elapsed time
                animationTime = 0;
            }
        }
开发者ID:PhilMoc,项目名称:Meteorocks,代码行数:30,代码来源:Sprite.cs

示例8: GetAllNotices

        public static List<Notices> GetAllNotices(string link)
        {
            string htmlPage = "";
            List<string> NoticeTitles = new List<string>();
            List<string> NoticeDates = new List<string>();
            List<string> NoticeUrl = new List<string>();

            List<Notices> Notices = new List<Notices>();

            using(var client = new WebClient())
            {
                Uri weblink = new Uri(link, UriKind.Absolute);
                htmlPage = client.DownloadString(weblink);
            }

            NoticeTitles = PatternHelper.GetNoticeTitle(htmlPage);
            NoticeDates = PatternHelper.GetNoticeDate(htmlPage);
            NoticeUrl = PatternHelper.GetNoticeLink(htmlPage);

            foreach(var item in NoticeTitles)
            {
                Notices.Add(new Notices {
                    Title = item,
                    Date = NoticeDates[NoticeTitles.IndexOf(item)],
                    Url = NoticeUrl[NoticeTitles.IndexOf(item)]
                });
            }

            return Notices;
        }
开发者ID:Rahim373,项目名称:UIU-Web-API,代码行数:30,代码来源:HtmlHelperClass.cs

示例9: CheckPostImport

        internal static List<Block> CheckPostImport(List<Block> ret)
        {
            if (ret == null) return null;

            var lastImport = ret.LastOrDefault(r => r is Model.Import);
            var firstNonImport = ret.FirstOrDefault(r => !(r is Model.Import));

            if (lastImport == null || firstNonImport == null)
            {
                return ret;
            }

            var lix = ret.IndexOf(lastImport);
            var fnix = ret.IndexOf(firstNonImport);

            if (lix != -1 && fnix != -1)
            {
                if (fnix < lix)
                {
                    for (int i = fnix; i < ret.Count; i++)
                    {
                        if (ret[i] is Model.Import)
                        {
                            Current.RecordWarning(ErrorType.Parser, ret[i], "@import should appear before any other statements.  Statement will be moved.");
                        }
                    }
                }
            }

            return ret;
        }
开发者ID:repos-css,项目名称:More,代码行数:31,代码来源:Parse.cs

示例10: Main

        static void Main()
        {
            Console.WriteLine("Enter some text to see how many times each word appears:");
            string text = Console.ReadLine();
            string[] textSplitted = text.Split(',', ' ');

            List<string> words = new List<string>();
            List<int> counter = new List<int>();

            for (int i = 0; i < textSplitted.Length; i++)
            {
                string currentWord = textSplitted[i];
                if (currentWord != "")
                {
                    if (words.IndexOf(currentWord) == -1)
                    {
                        words.Add(currentWord);
                        counter.Add(1);
                    }
                    else
                    {
                        int index = words.IndexOf(currentWord);
                        counter[index]++;
                    }
                }
            }

            Console.WriteLine("Letters : Appearances");
            for (int i = 0; i < words.Count; i++)
            {
                Console.WriteLine("{0} - {1}", words[i], counter[i]);
            }
        }
开发者ID:RobinJS,项目名称:dotNET,代码行数:33,代码来源:WordAppearances.cs

示例11: Main

        static void Main()
        {
            Console.WriteLine("Enter some text to see how many times each letter appears:");
            string text = Console.ReadLine();

            List<char> letters = new List<char>();
            List<int> counter = new List<int>();

            for (int i = 0; i < text.Length; i++)
            {
                char currentLetter = text[i];
                if (currentLetter != ' ')
                {
                    if (letters.IndexOf(currentLetter) == -1)
                    {
                        letters.Add(currentLetter);
                        counter.Add(1);
                    }
                    else
                    {
                        int index = letters.IndexOf(currentLetter);
                        counter[index]++;
                    }
                }
            }

            Console.WriteLine("Letters : Appearances");
            for (int i = 0; i < letters.Count; i++)
            {
                Console.WriteLine("{0} - {1}", letters[i], counter[i]);
            }
        }
开发者ID:RobinJS,项目名称:dotNET,代码行数:32,代码来源:LettersAppearances.cs

示例12: Main

    static void Main()
    {
        string number = Console.ReadLine();

        List<string> digits = new List<string>();

        for (char i = 'A'; i <= 'Z'; i++)
            digits.Add(i.ToString());

        for (char i = 'a'; i <= 'f'; i++)
            for (char j = 'A'; j <= 'Z'; j++)
                digits.Add(i.ToString() + j.ToString());

        if (number.Length == 1)
        {
            Console.WriteLine(digits.IndexOf(number[0].ToString()));
            return;
        }

        long result = 0, pow = 0;

        for (int i = number.Length - 1; i >= 0; i--)
        {
            // Example with number aFG...

            string left = number[i - 1].ToString(); // Found: F
            string right = number[i].ToString(); // Found: G

            if (i - 2 >= 0 && char.IsLower(number[i - 2])) // Check: aFG
            {
                left = number[i - 2] + "" + number[i - 1]; // Correct numbers: aF and G
                i--;
            }

            int index = digits.IndexOf(left + right); // Finds only numbers from type aF, bG, pL, etc...

            if (index != -1)
            {
                // Found one number
                result += index * (long)Math.Pow(168, pow++);
            }
            else
            {
                // There are two numbers, example: FG => calculates its values
                result += digits.IndexOf(right) * (long)Math.Pow(168, pow++) +
                          digits.IndexOf(left) * (long)Math.Pow(168, pow++);
            }

            i--;

            if (i - 1 == 0)
            {
                // Only one number left
                result += digits.IndexOf(number[0].ToString()) * (long)Math.Pow(168, pow);
                break;
            }
        }

        Console.WriteLine(result);
    }
开发者ID:jesconsa,项目名称:Telerik-Academy,代码行数:60,代码来源:1.+Durankulak+Numbers+(another).cs

示例13: EditCustomerInformationModel

        public EditCustomerInformationModel(Customer customer, IEnumerable<Country> countries)
        {
            Firstname = customer.Firstname;
            Lastname = customer.Lastname;
            Email = customer.Email;
            //Birthday = customer.Birthday ?? DateTime.MinValue;
            SelectedGenderType = (int) customer.Gender;

            AvailableCountries = countries.Select(x => new SelectListItem { Selected = x.Name.Trim() == customer.Country.Trim(), Text = x.Name.Trim(), Value = x.Name.Trim() }).ToList();
            AvailableCountries.Insert(0, new SelectListItem { Selected = false, Text = "I'd rather not say", Value = string.Empty });

            Genders = new List<SelectListItem>();
            Genders.Add(new SelectListItem { Selected = false, Text = "I'd rather not say", Value = "0" });
            Genders.Add(new SelectListItem { Selected = false, Text = GenderTypeEnum.Male.ToString(), Value = ((int)GenderTypeEnum.Male).ToString() });
            Genders.Add(new SelectListItem { Selected = false, Text = GenderTypeEnum.Female.ToString(), Value = ((int)GenderTypeEnum.Female).ToString() });

            SelectedBirthDate = (customer.Birthday.HasValue) ? customer.Birthday.Value.Day : 0;
            SelectedBirthMonth = (customer.Birthday.HasValue) ? customer.Birthday.Value.Month : 0;
            SelectedBirthYear = (customer.Birthday.HasValue) ? customer.Birthday.Value.Year : 1970;

            BirthDate = new List<SelectListItem>{ new SelectListItem { Selected = false, Text = "Day", Value = "0" } };
            BirthDate.AddRange(Enumerable.Range(1, 31).Select(x => new SelectListItem { Selected = x == SelectedBirthDate, Text = x.ToString(), Value = x.ToString() }).ToList());

            var months = new List<string> { "Month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
            BirthMonth = new List<SelectListItem>();
            months.ForEach(x => BirthMonth.Add(new SelectListItem { Selected = months.IndexOf(x) == SelectedBirthMonth, Text = x, Value = months.IndexOf(x).ToString() }));
        }
开发者ID:mkhj,项目名称:EcoHotels,代码行数:27,代码来源:CustomerModels.cs

示例14: HandleInput

        public void HandleInput(List<Keys> input)
        {
            if (input.IndexOf(Keys.Left) > -1)
            {
                MoveLeftIfPossible();
            }

            if (input.IndexOf(Keys.Right) > -1)
            {
                MoveRightIfPossible();
            }

            if (input.IndexOf(Keys.PageDown) > -1)
            {
                field.RotateBlockRight();
            }

            if (input.IndexOf(Keys.PageUp) > -1)
            {
                field.RotateBlockLeft();
            }

            if (input.IndexOf(Keys.Space) > -1)
            {
                field.FixBlock();
            }
        }
开发者ID:ReneB,项目名称:TddTetris,代码行数:27,代码来源:GameMechanics.cs

示例15: Start

        void Start()
        {
            if (instance != null)
                throw new Exception("Error: multiple LocationGraphs present");
            instance = this;

            locations = new List<Location>();

            Component[] components = this.gameObject.GetComponents(typeof(Edge));
            Edge[] edges = new Edge[components.Length];
            for (int i = 0; i < components.Length; i++) {
                edges[i] = (Edge) components[i];

                if (!locations.Contains(edges[i].one))
                    locations.Add(edges[i].one);
                if (!locations.Contains(edges[i].two))
                    locations.Add(edges[i].two);
            }

            graph = new bool[locations.Count, locations.Count];
            for (int i = 0; i < graph.GetLength(0); i++) {
                for (int j = 0; j < graph.GetLength(1); j++) {
                    graph[i,j] = inverse;
                }
            }

            foreach (Edge edge in edges) {
                int indexOne = locations.IndexOf(edge.one);
                int indexTwo = locations.IndexOf(edge.two);

                graph[indexOne, indexTwo] = !inverse;
                graph[indexTwo, indexOne] = !inverse;
            }
        }
开发者ID:MarjieVolk,项目名称:BeautyAndTheBeast,代码行数:34,代码来源:LocationGraph.cs


注:本文中的List.IndexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。