Cash Wu Geek
BlogTagsAbout
Published on
2017年6月3日

C# - linq select get index

使用 Linq 的 select 時要拿到資料 index 的寫法

string[] fruits = { "apple", "banana", "mango", "orange", "passionfruit", "grape" };

var query = fruits.Select((fruit, index) => new { index, str = fruit.Substring(0, index) });
foreach (var obj in query)
{
    obj.Dump();
}

← Vue - Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead
Evernote 使用 app 新增記事時自動設定標題 →
mailMailgithubGitHubfacebookFacebookxX
Cash
•
© 2025
•
Cash Wu Geek
Tailwind Nextjs Theme