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
public readonly struct Point | |
{ | |
public double X { get; } | |
public double Y { get; } | |
public double Distance { get; } | |
public Point(double x, double y) => | |
(X, Y, Distance) = (x, y, x * y); | |
public static bool operator == (Point left, Point right) => |
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
public void Check(Person person) | |
{ | |
// _ : variable that is thrown away by compiler | |
_ = person ?? throw new ArgumentNullException(nameof(person)); | |
// code here ... | |
} |
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
public class Program | |
{ | |
public static void Main() | |
{ | |
Console.WriteLine(PeakTimeCalculator(DateTime.Now, true)); | |
Console.WriteLine(PeakTimeCalculator(DateTime.Now.AddMonths(3), false)); | |
} | |
// Calculates costs based on month and whether or not its peak set | |
public static decimal PeakTimeCalculator(DateTime date, bool isPeak) => |
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 Newtonsoft.Json; | |
... | |
var client = new HttpClient(); | |
var httpRequestMessage = new HttpRequestMessage | |
{ | |
Method = HttpMethod.Post, | |
RequestUri = new Uri("https://api.clickatell.com/rest/message"), | |
Headers = { | |
{ HttpRequestHeader.Authorization.ToString(), "Bearer xxxxxxxxxxxxxxxxxxxx" }, |
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
type SearchParams = { | |
title?:string; | |
publishYear?:string; | |
author?:string; | |
} | |
type Book = { | |
isbn:string; | |
title:string; | |
publishYear:string; |
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.ComponentModel; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
var dataType = typeof(Double); | |
var converter = TypeDescriptor.GetConverter(dataType); |
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
choco install git -y | |
choco install git-credential-manager-for-windows -y | |
choco install notepadplusplus -y | |
choco install nodejs-lts -y | |
choco install slack -y | |
choco install docker-desktop -y | |
choco install f.lux -y | |
choco install vscode -y | |
choco install googlechrome -y | |
choco install firefox-dev -y |
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
// Import: <PackageReference Include="DotNetZip" Version="1.15.0" /> | |
namespace BigFileZipper | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string[] filenames = { | |
@"PUT PATH TO REALLY BIG FILES HERE", |
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
var dbEntity = Assembly.GetExecutingAssembly() | |
.GetTypes() | |
.Where(t => | |
t.GetInterface(nameof(IDbEntity)) != null) | |
.Select(x => Activator.CreateInstance(x) as IDbEntity) | |
.FirstOrDefault(); | |
var dbRepository = ConstructDatabaseRepository(dbEntity, _dbRepository.DbContext); | |
// Magic |
OlderNewer