Skip to content

Instantly share code, notes, and snippets.

View BillWagner's full-sized avatar
🎸
Working a normal schedule again

Bill Wagner BillWagner

🎸
Working a normal schedule again
View GitHub Profile
@BillWagner
BillWagner / EvalOrder
Created September 5, 2013 20:47
This shows that the evaluation order of parameters is dictated by their order all that call site, not the order in the function definition.
class Program
{
static void Main(string[] args)
{
int i = 5;
EvalOrder(++i, i++); // 6, 6
Console.WriteLine(i); // 7
EvalOrder(second: ++i, first: ++i); // 9, 8
Console.WriteLine(i); // 9
@BillWagner
BillWagner / Microsoft.PowerShell_profile.ps1
Last active March 12, 2016 18:07
Profile.ps1 that adds VS tools path and git tools path to your shell.
"Setting VS 2015 Vars"
#Set environment variables for Visual Studio Command Prompt
pushd 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools'
cmd /c "vsvars32.bat&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
}
popd
@BillWagner
BillWagner / AnyAndAll.cs
Created July 28, 2016 15:54
Any and All Puzzle
using static System.Console;
using System.Collections.Generic;
using System.Linq;
namespace AnyAndAll
{
public class Program
{
public static void Main(string[] args)
{
@BillWagner
BillWagner / funcyCSharp.cs
Created May 2, 2017 21:16
local functions and lambdas and expressions, oh my
static void Main(string[] args)
{
Func<int> foo = () =>
{
int M1()
{
return 19;
}
return M1() + M2();
@BillWagner
BillWagner / git_profile.sp1
Created October 10, 2017 19:34
Load Posh-Git from GitHub desktop in every powershell instance
"Loading PoshGit..."
. (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1")
. $env:github_posh_git\profile.example.ps1
@BillWagner
BillWagner / main.cs
Last active December 12, 2017 16:04
using System;
using System.Threading.Tasks;
public class Example
{
public static async Task<int> Main()
{
Console.WriteLine("Calling DoWorkAsync");
var taskResult = DoWorkAsync(-5);
@BillWagner
BillWagner / program.cs
Created January 30, 2018 15:25
Equality and Symmetry
using System;
namespace symmetry
{
public class Person : IEquatable<Person>
{
public string FirstName {get;set;}
public string LastName {get;set;}
public bool Equals(Person other)
@BillWagner
BillWagner / new-toc.md
Last active August 29, 2019 01:11
Proposed new TOC for the C# Guide

Notes

Important: This is a point-in-time snapshot of background work used to create a formal plan. The updated issues in the docs repo more accurately reflect the plan.

Using this resource:

  • Consider the H2s as a good roadmap for where content should go.
  • Consider lower level headers inasmuch as they show where existing articles will move over time.
  • Articles will be combined and archived to keep the C# guide current.
@BillWagner
BillWagner / program.cs
Last active July 14, 2020 14:47
Program to update section references in the C# standard (markdown version)
using System;
using System.Linq;
using System.IO;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text;
// Consider using the default anchors.
// These anchors are of the form "-1723-arrays-and-the-generic-collection-interfaces"