Last active
August 29, 2015 14:26
-
-
Save akehoyayoi/98a6f175ea48e03815c9 to your computer and use it in GitHub Desktop.
Guidの部分文字列が被るかどうかのテスト(コンソールアプリ)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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