Skip to content

Instantly share code, notes, and snippets.

@akehoyayoi
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akehoyayoi/98a6f175ea48e03815c9 to your computer and use it in GitHub Desktop.
Save akehoyayoi/98a6f175ea48e03815c9 to your computer and use it in GitHub Desktop.
Guidの部分文字列が被るかどうかのテスト(コンソールアプリ)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var count = 10000;
if (args.Length > 0) {
count = Convert.ToInt32(args[0]);
}
var map = new Dictionary<string, int>();
for (int i = 0; i < count; i++)
{
var guid = Guid.NewGuid();
var sub = guid.ToString().Substring(0, 8);
if (map.ContainsKey(sub))
{
map[sub] += 1;
}
else
{
map[sub] = 1;
}
}
foreach (var p in map)
{
if (p.Value > 1)
{
Console.WriteLine("{0}:{1}",p.Key,p.Value);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment