Skip to content

Instantly share code, notes, and snippets.

@121jigowatts
Created March 20, 2015 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 121jigowatts/f3389d31c8f3cb02b15d to your computer and use it in GitHub Desktop.
Save 121jigowatts/f3389d31c8f3cb02b15d to your computer and use it in GitHub Desktop.
[LINQ] 型をフィルタしてインデックス付与する
public void MyOfType<T>(IEnumerable<object> source)
{
var x = source.OfType<T>()
.Select((value, index) => string.Format("{0}:{1}", index + 1, value));
foreach (var item in x)
{
Console.WriteLine(item);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment