1
0
mirror of synced 2026-10-07 23:37:34 +08:00

docs: optimize C# readme.md

This commit is contained in:
AuroraTea
2022-12-17 22:16:35 +08:00
parent d4b9a26fca
commit ad3fc5f3ab

View File

@@ -6,14 +6,19 @@
(支持:.net framework4.6.1+/.net core 2.0+/.net5/.net6+/mono5.4+/Unity 2018+/Xamarin/)
## 引用 nuget 包
```
```xml
<PackageReference Include="Yitter.IdGenerator" Version="1.0.*" />
```
或者使用nuget CLI时
```shell
nuget install Yitter.IdGenerator
```
更多引入方式请点击查看: [nuget.org/packages/Yitter.IdGenerator](https://www.nuget.org/packages/Yitter.IdGenerator)
## 调用示例(C#)
第1步,**全局** 初始化(应用程序启动时执行一次):
```
```cs
// 创建 IdGeneratorOptions 对象,可在构造函数中输入 WorkerId:
var options = new IdGeneratorOptions(Your_Unique_Worker_Id);
// options.WorkerIdBitLength = 10; // 默认值6,限定 WorkerId 最大值为2^6-1,即默认最多支持64个节点。
@@ -28,7 +33,7 @@ YitIdHelper.SetIdGenerator(options);
```
第2步,生成ID:
```
```cs
// 初始化后,在任何需要生成ID的地方,调用以下方法:
var newId = YitIdHelper.NextId();
```