Random sampling without repetitions

I want to assign every unit I create an ID. What’s the best way to randomly sample K from N unique numbers? At present I’m doing it in a very uncreative way, but just sampling a number for each unit capped at a (large) N. Obviously this doesn’t preclude randomly sampling the same number twice or more. In numpy or pytorch it’s a piece of cake, but so far I’ve found C# math arsenal rather short.

Why not just count up from 0? Why make them random at all?
Also, you can use Instance ID if your IDs don’t need to be persistent.

There are many ways to pick random numbers, shuffling lists of them, making it statistically rare by using a large range, tracking those you’ve already generated… stack overflow probably has loads of suggestions. But why?

I don’t really see how this is complicated (unless i’m missing something).
How about pre-generate a list containing all the possible IDs your want , shuffle it , then just use it a queue , where whenever you want a new ID just pop the first element out , deleted it , and return it.
Does that work ?