Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. 3 paź 2014 · You can use the ElementAt extension method on the list. For example: // Get the first item from the list using System.Linq; var myList = new List<string> { "Yes", "No", "Maybe"}; var firstItem = myList.ElementAt (0); // Do something with firstItem. edited May 20, 2018 at 1:23.

  2. What I'm trying to achieve is a function where I read a value by passing its index, i.e. index =1 for the first value in the file, or index =5 for the fifth value in the file etc.. Double GetValue (int index) {.

  3. C# provides two solid ways to access the data by the index. The indexer and the ElementAt function. They work in similar ways but the indexer only works on certain IEnumerable types ElementAt will work on any IEnumerable type which includes a list.

  4. Get Items from List in C# Here are some examples of working with lists in C#: Example 1: Getting Items from a List by Index. List<string> names = new List<string> { "Alice", "Bob", "Charlie", "Dave" }; string secondName = names [1]; Console.WriteLine (secondName); // Output: "Bob"

  5. 30 wrz 2023 · Learn the 2 ways to get a list item by index in C#: using an indexer or a Linq ElementAt() call.

  6. 5 gru 2021 · This post will discuss how to find the index of an element in a list in C#. The solution should either return the index of the first occurrence of the required element or -1 if it is not present in the list. 1. Using List<T>.IndexOf () method.

  7. 5 sie 2011 · IEnumerable<Person> allAgedTwenty = myList.Where<Person>( x => return x.Age == 20; ); IEnumerable<int> indices = allAgedTwenty.Select<Person,int>( x => myList.IndexOf(x) ); The first case will get you only one int and the second case will leave you with a list of ints. Best Regards, —MRB

  1. Ludzie szukają również