Skip to content

Instantly share code, notes, and snippets.

View hasan-hasanov's full-sized avatar

Hasan Hasanov hasan-hasanov

View GitHub Profile
@byme8
byme8 / DuckInterface.md
Last active January 5, 2021 09:27
DuckInterface

DuckInterface

I was playing with new .Net 5 and the Source Generator lately and got an idea that it is possible to add "duck typing" support to C#. I would say it is purely academic(no one will use it in production I hope), but it is fun stuff so I decided to try.

The nuget package with results you can find here

Nuget

The repository is here: https://github.com/byme8/DuckInterface

@duncansmart
duncansmart / gist:3982912
Created October 30, 2012 20:45
Guid compression
static string compressGuid(Guid guid)
{
// "MspzuC2oLkKjoUEgZrbJFg=="
return Convert.ToBase64String(guid.ToByteArray())
.Substring(0, 22)
.Replace('+', '-')
.Replace('/', '_');
}