This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Account | |
{ | |
public void Main() | |
{ | |
Action<string> action = (str) => Console.WriteLine(str); | |
action("test"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace Fluent | |
{ | |
public static class Program | |
{ | |
public static void Main() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace Chain | |
{ | |
internal static class Program | |
{ | |
private static void Main() | |
{ | |
var ch = new ChildHairdresser(); | |
var wm = new WomenHairDresser(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
OlderNewer