Implement Kotlin's withIndex in C#