gpt4 book ai didi

c# - 如何在不使用数据库的情况下生成 int/long 序列标识符?

转载 作者:太空宇宙 更新时间:2023-11-03 16:46:07 24 4
gpt4 key购买 nike

我想在 C# 中生成 int/long 类型的序列标识符,但我不想使用数据库来存储生成的值,我该怎么做? CPU 滴答计数器会有帮助吗?或者您还有其他想法吗?

最佳答案

试试这个:

using Microsoft.Win32;


RegistryKey key =
Registry.LocalMachine.CreateSubKey ("The Right Value");

private void InitializeTheKey()
{

this.MaxIndex = 0; // Or any other value ..

}


public Int32 MaxIndex
{
get{ return key.GetValue("MaxIndex"); }
set{ key.SetValue ("MaxIndex", value); }
}

public Int32 GetNewIndex()
{

this.MaxIndex += 1;
return this.MaxIndex;

}

WARNING: DO NOT PLAY WITH THE REGISTRY. If you do not know what you are doing, you can cause any number of costly problems. Use this code at your own risk.

关于c# - 如何在不使用数据库的情况下生成 int/long 序列标识符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5933060/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com