Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. 3 gru 2011 · lambda expression for traversing through an array. i'm a lambda noob. i am looking for a way using anonymous methods to sum up the result of a count variable in my items. class SomeObject { public int Count {get;} } SomeObject [] items = new SomeObject [] {......};

  2. Loop Through an Array. You can loop through the array elements with the for loop, and use the Length property to specify how many times the loop should run. The following example outputs all elements in the cars array:

  3. 4 lut 2021 · An iterator is a method in C# which is used in an array or in collections like the list, etc. to retrieve elements one by one. Or in other words, we can say that an iterator is used to perform an iteration over the collections. This feature is introduced in C# 2.0.

  4. 11 kwi 2023 · In the following example, the Stack<T> generic class implements the IEnumerable<T> generic interface. The Push method assigns values to an array of type T . The GetEnumerator method returns the array values by using the yield return statement.

  5. When you're coding in C#, you often need to work with arrays. These are vital data structures that let you store collections of items. But how do you efficiently loop through arrays?

  6. 23 lip 2024 · The traditional for loop is a common and straightforward way to iterate through arrays in C#. Here's an example of how you can use a for loop to loop through an array: int [] numbers = { 1, 2, 3, 4, 5 }; for (int i = 0; i < numbers.Length; i++) { Console.WriteLine(numbers[i]); } Using foreach Loop.

  7. 12 mar 2024 · The following code example demonstrates how a single generic method that takes an IList<T> input parameter can iterate through both a list and an array, in this case an array of integers. C# Copy. class Program . { static void Main() . { int[] arr = [0, 1, 2, 3, 4]; List<int> list = new List<int>(); for (int x = 5; x < 10; x++)

  1. Ludzie szukają również