Skip to content

Instantly share code, notes, and snippets.

@tenor
tenor / [1] switch_with_patterns.cs
Last active September 29, 2016 17:49
New features in C# 7
//See https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/ for more details.
abstract class Shape {}
abstract class Polygon : Shape
{
public virtual string NickName {get;}
public virtual int Sides {get;}
}
class Square : Polygon
Enumerable.Range(1,10).Select(i => new Random().Next()).ToArray()
@tenor
tenor / immutable_collections.cs
Created December 15, 2014 17:25
Immutable Collections Example on CSharpPad.com
using static
System.Collections.Immutable.ImmutableArray;
Create<int>(5,4,3,2,1)
@tenor
tenor / null_conditional_operator.cs
Created December 15, 2014 17:08
C# 6 Examples on CSharpPad.com
string s = null;
s?.Length
@tenor
tenor / backwards.cs
Created February 26, 2014 00:18
These programs display a list of the names of single digits
// This program outputs the names of a given list of digits backwards
//
string GetDigitName(int digit)
{
switch(digit)
{
case 0: return "zero";
case 1: return "one";
case 2: return "two";
@tenor
tenor / blah?77.cs
Created February 18, 2014 18:17
? test
nn
@tenor
tenor / My Mira,;|max.cs
Created February 18, 2014 18:16
CS Test
noop
@tenor
tenor / MyVBFile.vb
Created February 18, 2014 18:07
My VB File
My VB
Test
#include <iostream>
#include <string>
template< class ForwardIt1, class ForwardIt2 >
bool is_subset(ForwardIt1 first1, ForwardIt1 last1,
ForwardIt2 first2, ForwardIt2 last2)
{
auto initial = first2;
for (; (first1 != last1) && (first2 != last2); ++first1)