docs: optimize C# readme.md
This commit is contained in:
@@ -6,14 +6,19 @@
|
|||||||
(支持:.net framework4.6.1+/.net core 2.0+/.net5/.net6+/mono5.4+/Unity 2018+/Xamarin/)
|
(支持:.net framework4.6.1+/.net core 2.0+/.net5/.net6+/mono5.4+/Unity 2018+/Xamarin/)
|
||||||
|
|
||||||
## 引用 nuget 包
|
## 引用 nuget 包
|
||||||
```
|
```xml
|
||||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.*" />
|
<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#)
|
## 调用示例(C#)
|
||||||
|
|
||||||
第1步,**全局** 初始化(应用程序启动时执行一次):
|
第1步,**全局** 初始化(应用程序启动时执行一次):
|
||||||
```
|
```cs
|
||||||
// 创建 IdGeneratorOptions 对象,可在构造函数中输入 WorkerId:
|
// 创建 IdGeneratorOptions 对象,可在构造函数中输入 WorkerId:
|
||||||
var options = new IdGeneratorOptions(Your_Unique_Worker_Id);
|
var options = new IdGeneratorOptions(Your_Unique_Worker_Id);
|
||||||
// options.WorkerIdBitLength = 10; // 默认值6,限定 WorkerId 最大值为2^6-1,即默认最多支持64个节点。
|
// options.WorkerIdBitLength = 10; // 默认值6,限定 WorkerId 最大值为2^6-1,即默认最多支持64个节点。
|
||||||
@@ -28,7 +33,7 @@ YitIdHelper.SetIdGenerator(options);
|
|||||||
```
|
```
|
||||||
|
|
||||||
第2步,生成ID:
|
第2步,生成ID:
|
||||||
```
|
```cs
|
||||||
// 初始化后,在任何需要生成ID的地方,调用以下方法:
|
// 初始化后,在任何需要生成ID的地方,调用以下方法:
|
||||||
var newId = YitIdHelper.NextId();
|
var newId = YitIdHelper.NextId();
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user