Z
Z
Zefirot2021-07-03 11:11:52
C++ / C#
Zefirot, 2021-07-03 11:11:52

What is the best way to make a non-long unique value?

I have two types of objects - static and dynamic, of course I simply number static ones, but dynamic ones need to be given unique values, since there can be many of them and they can often appear and be destroyed, the most important thing is that their keys do not repeat, and it’s better of course, so that they are not too long, otherwise I now do them like this ...

private string GenerateNum(){
        string num = DateTime.UtcNow.ToString() + UnityEngine.Random.Range(0f, 10000f) + DateTime.UtcNow.ToString() + UnityEngine.Random.Range(0f, 10000f);
        return num;
        }

I would like no more than 10 characters ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
HemulGM, 2021-07-03
@Zefirot

GetTickCount
Or you can generate a GUID

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question