Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

get both item and index in c#

// add this to your namespace
public static IEnumerable<(T item, int index)> WithIndex<T>(this IEnumerable<T> source)
{
    return source.Select((item, index) => (item, index));
}

//do something like this

foreach (var (item, index) in collection.WithIndex())
{
    DoSomething(item, index);
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity making homing missile 
Csharp :: how to send button name for method in c# 
Csharp :: how to use yield in c# 
Csharp :: how to set border for groupbox in c# 
Csharp :: unity time scale 
Csharp :: httpget query parameters c# 
Csharp :: C# round number of digits after decimal point 
Csharp :: how to remove all comma from string c# 
Csharp :: string substring c# before 
Csharp :: Print arraylist values to console unity 
Csharp :: prevent system shutdown c# 
Csharp :: regex for accepting a file name c# 
Csharp :: visual studio c# mark class deprecated 
Csharp :: how to turn on/off Particle System unity 
Csharp :: linq string comparison case insensitive 
Csharp :: asp net img src path from database 
Csharp :: unity pause coroutine 
Csharp :: c# list add to list 
Csharp :: bytes size c# 
Csharp :: how to see if a number is even c# 
Csharp :: freeze scene unity 
Csharp :: render section asp.net mvc layout 
Csharp :: c# clear console read chache 
Csharp :: get index brushes properties c# 
Csharp :: photon2 addcalbacktarget 
Csharp :: What are logic gates? 
Csharp :: cdn providers 
Csharp :: get script directory c# 
Csharp :: unity rollaball 
Csharp :: cant see my classes in inspector 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =