Skip to content

Instantly share code, notes, and snippets.

@kokudori
Created February 19, 2015 06:29
Show Gist options
  • Save kokudori/f6f32d5146909938c522 to your computer and use it in GitHub Desktop.
Save kokudori/f6f32d5146909938c522 to your computer and use it in GitHub Desktop.
.NETのHashSetは集合だから順序を持たないっぽい?(Addが一貫してない?)
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
namespace ConsoleApplication1
{
enum Meta
{
Hoge,
Piyo
}
class Program
{
static void Main(string[] args)
{
var hash = new HashSet<Meta>();
hash.Add(Meta.Hoge);
hash.Add(Meta.Piyo);
Contract.Assert(hash.Last() == Meta.Piyo);
hash.Remove(Meta.Hoge);
hash.Add(Meta.Hoge);
Contract.Assert(hash.Last() == Meta.Piyo);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment