CSharp examples for Language Basics:Tuple
Return Tuple from method
using System;/* ww w. ja v a 2s. co m*/ using System.Collections.Generic; using System.Linq; static class Indexing { static void Main() { string[] array = { "first", "second", "third" }; foreach (var pair in array.WithIndex()) { Console.WriteLine(pair); } } static IEnumerable<(T value, int index)> WithIndex<T> (this IEnumerable<T> source) => source.Select((value, index) => (value, index)); }