Skip to content

Instantly share code, notes, and snippets.

@masaru-b-cl
Created April 27, 2012 05:21
Show Gist options
  • Save masaru-b-cl/2506114 to your computer and use it in GitHub Desktop.
Save masaru-b-cl/2506114 to your computer and use it in GitHub Desktop.
ExceptAt拡張メソッド
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
static class IEnumerableExtensions
{
public static IEnumerable<T> ExceptAt<T>(this IEnumerable<T> source, int index)
{
return source.Where((x, i) => i != index);
}
}
class Program
{
static void Main(string[] args)
{
var source = Enumerable.Range(0, 5);
foreach (var item in source.ExceptAt(2))
{
Console.WriteLine(item);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment