Skip to content

Instantly share code, notes, and snippets.

@StephenCleary
StephenCleary / FnvHash.cs
Created October 6, 2019 14:15
FNV-1a hash in C#
/// <summary>
/// A hash combiner that is implemented with the Fowler/Noll/Vo algorithm (FNV-1a). This is a mutable struct for performance reasons.
/// </summary>
public struct FnvHash
{
/// <summary>
/// The starting point of the FNV hash.
/// </summary>
public const int Offset = unchecked((int)2166136261);
@robertpi
robertpi / gist:2964793
Created June 21, 2012 09:18
F# record implementing an interface
namespace MyNamespace
type IMyInterface =
abstract GetValue: unit -> string
type MyRecord =
{ MyField1: int
MyField2: string }
interface IMyInterface with
member x.GetValue() = x.MyField2