Skip to content

Instantly share code, notes, and snippets.

View kostrse's full-sized avatar

Sergey Kostrukov kostrse

View GitHub Profile
@kostrse
kostrse / EnumerableLastNth.cs
Last active February 27, 2016 19:28
Last N-th of IEnumerable
public static class LinkedListExtensions
{
public static T Last<T>(this IEnumerable<T> items, int index)
{
T[] keepItems = new T[index];
int position = 0;
int count = 0;
foreach (var item in items)
@kostrse
kostrse / gist:3687221
Created September 9, 2012 20:52
CheckAccountNumber - checks checksum for Russian bank account number
private static bool CheckAccountNumber(string bankNumber, string accountNumber)
{
int[] mask = new[] { 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1 };
if (bankNumber.Length < 3)
{
Console.WriteLine("Incorrect bank number.");
return false;
}