.net开发还在使用guid吗?下面几种id生成器更加合适
<ItemGroup> <PackageReference Include="IdGen" Version="3.0.5" /> <PackageReference Include="Nanoid" Version="3.0.0" /> <PackageReference Include="Snowflake.Core" Version="2.0.0" /> </ItemGroup>
public async Task<string> DoworkIDs() { // IdGenerator idgen = new IdGenerator(); // long getid = idgen.CreateId(); string nanoidStr = await NanoidDotNet.Nanoid.GenerateAsync(); long getId3 = new IdGen.IdGenerator(3).CreateId(); long getId10 = new IdGen.IdGenerator(10).CreateId(); Snowflake.Core.IdWorker snowflake = new Snowflake.Core.IdWorker(1,2,8); long snowflakeId = snowflake.NextId(); return await Task.FromResult($"==getId3=={getId3},=====getId10={getId10},=====nanoidStr={nanoidStr}===snowflakeId=={snowflakeId}"); }
如有疑问或者错误的地方,请跟帖,本人会第一时间答复以及相互学习,谢谢!个人会不断的上传自己的学习心得!
好了今天就先到这里,下次有时间再更新,如果存在不合理的地方,欢迎大家多多指教留言!!!