Trading card game uniqe id generation

So in making a trading card game, I need to make sure every trading card has a unique ID, but I need the first character needs to identify what type of card it is, would it be best practice to use an ID generator and concatenate the identifier?

p.s. I low-key want the ID’s to be ordered so that if you got all the cards you could kind of see the order each card was released but I feel like that’s a bad idea just wanted to share this thought.

I personally don’t see whats wrong with adding some identifier information into the identifier if you want to do that

I guess you want something like

I would use GUIDs to do this

So you could have
CardID: 1 - Lets you know which card it is
Day - Month - Year let you know when it was released
GUID is the unique reference for that particular card

In code this could look like

public void GenerateNewCards(int numOfCards, string cardID, string dateInfo)
        for (int i = 0; i < numOfCards; i++)
            string newCardReference = string.Format("{0}-{1}-{2}", cardID,dateInfo, System.Guid.NewGuid().ToString());

I ran that for 5 cards and got



This should create you results that are unique and you can read the first bit to know what the card is and when it was released. You can then parse that string later to get that information out

In my games, I need a persistent, unique identifier when saving game state so that it can be loaded again on another play session. I accomplish this with the Guid class: Guid Struct (System) | Microsoft Learn

E.g. string saveID = Guid.NewGuid().ToString(); If you need to determine an order to it, just add some arbitrary letters to it: string cardID = "a" + Guid.NewGuid().ToString(). "a" can be replaced with an array entry as well. Consider: string[] prefixes = new string[] { "a", "b", "c", ... "aa", "ab", "ac"} ;