This file contains hidden or 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
package main | |
import ( | |
"crypto/sha256" | |
"encoding/binary" | |
"flag" | |
"fmt" | |
"math/rand" | |
"os" |
This file contains hidden or 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
public static void Main() | |
{ | |
var jim = new Person("Jim", "Halpert"); | |
var dwight = jim; | |
Mutate(dwight); | |
Console.WriteLine($"Hello! I'm {jim.FirstName} {jim.LastName}."); | |
Console.WriteLine($"Hello! I'm {dwight.FirstName} {dwight.LastName}."); | |
} |
This file contains hidden or 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
public class Program | |
{ | |
public static void Main() | |
{ | |
int x = 10; | |
Update(x); | |
Console.WriteLine($"x is {x}"); | |
} |
This file contains hidden or 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
var builder = WebApplication.CreateBuilder(args); | |
var app = builder.Build(); | |
app.MapGet("/", () => "Hello World!"); | |
app.Run(); |
This file contains hidden or 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
private static async Task Main(string[] args) | |
{ | |
var stopwatch = new Stopwatch(); | |
stopwatch.Start(); | |
var janeTask = DoWorkAsync("Jane", 1000); | |
var exceptionTask1 = WaitAndThrowExceptionAsync(1, 500); | |
var johnTask = DoWorkAsync("John", 2000); | |
var exceptionTask2 = WaitAndThrowExceptionAsync(2, 1500); |
This file contains hidden or 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
private static async Task Main(string[] args) | |
{ | |
var stopwatch = new Stopwatch(); | |
stopwatch.Start(); | |
var janeTask = DoWorkAsync("Jane", 1000); | |
var exceptionTask1 = WaitAndThrowExceptionAsync(1, 1500); | |
var johnTask = DoWorkAsync("John", 2000); | |
var exceptionTask2 = WaitAndThrowExceptionAsync(2, 500); |
This file contains hidden or 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
private static async Task Main(string[] args) | |
{ | |
var stopwatch = new Stopwatch(); | |
stopwatch.Start(); | |
var janeTask = DoWorkAsync("Jane", 1000); | |
var johnTask = DoWorkAsync("John", 2000); | |
await Task.WhenAll(janeTask, johnTask); |
This file contains hidden or 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
private static async Task Main(string[] args) | |
{ | |
var stopwatch = new Stopwatch(); | |
stopwatch.Start(); | |
await DoWorkAsync("Jane", 1000); | |
await DoWorkAsync("John", 2000); | |
stopwatch.Stop(); | |
Console.WriteLine($"Total Work took {stopwatch.ElapsedMilliseconds} ms"); |
This file contains hidden or 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
public class Shapes | |
{ | |
private static readonly AsyncLocal<string> _asyncLocal = new AsyncLocal<string>(); | |
static void Main(string[] args) | |
{ | |
SetValue("Square"); | |
Circle().GetAwaiter().GetResult(); | |
} |