Skip to content

Instantly share code, notes, and snippets.

View kolosovpetro's full-sized avatar

Petro Kolosov kolosovpetro

View GitHub Profile
using System;
using System.Collections.Generic;
public class CustomEnumerable
{
// A custom enumerator which has a Current property and a MoveNext() method, but does NOT implement IEnumerator.
public class CustomEnumerator
{
private readonly CustomEnumerable _enumerable;
private int _index = -1;
using System;
using System.Collections.Generic;
public class C {
public void M() {
var actions = new List<Action>();
for(var i = 0; i<10; i++)
{
actions.Add(() => Console.WriteLine(i));
}
using System;
using System.Collections.Generic;
using System.Linq;
public class C {
public void M() {
var col = Collection().ToList();
foreach(var item in col)
{
Console.WriteLine(item);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
public class C {
public async Task M() {
Console.WriteLine("Before await");
await Task.Delay(1000);
Console.WriteLine("After await");
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
public class C {
public void Main()
{
var str = new DisposableStruct();
using(str) {
using System;
class Account
{
public delegate void AccountHandler(string message);
public event AccountHandler Notify; // 1.Определение события
public Account(int sum)
{
Sum = sum;
}
public int Sum { get; private set;}
using System;
class Account
{
public void Main()
{
Action<string> action = (str) => Console.WriteLine(str);
action("test");
}
}
@kolosovpetro
kolosovpetro / FluentFilter.cs
Last active April 4, 2021 21:23
FluentFilter.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace Fluent
{
public static class Program
{
public static void Main()
{
@kolosovpetro
kolosovpetro / Chain.cs
Last active April 4, 2021 21:23
Chain
using System;
namespace Chain
{
internal static class Program
{
private static void Main()
{
var ch = new ChildHairdresser();
var wm = new WomenHairDresser();
using System;
namespace SolidRules.SRP
{
// SRP is not violated here
public class SrpFriendly
{
private readonly ConsoleNotifier _notifier = new ConsoleNotifier();
private readonly ConsoleReader _reader = new ConsoleReader();
private readonly StringValidator _validator = new StringValidator();