Question making inventory system

So I mainly code in pawn the San Andreas Multiplayer scripting language and have basic knowledge in C# and javascript and I use play maker for some basic networking stuff.

I’m currently scripting an inventory system for an open world zombie survival game I’m working on and need some guidance.

In Pawn you can use this type of code to determine the inventory system and item names.

enum ItemLIST
{
 ItemID,
    Name[128],
 Q,
 ObjectID,
}
new ItemIDs[][ItemLIST] = {
    {0, "NULL", 0, 0},
    {1, "Brassknuckles", 0, 331}, //30
    {2, "Golfclub", 0, 333}, //70
    {3, "Nitestick", 0, 334}, //40
    {4, "Knife", 9, 335}, //10
    {5, "Baseball Bat", 0, 336}, //30
    {6, "Shovel", 0, 337}, //40
    {7, "Poolstick", 0, 338}, //75
    {8, "Katana", 0, 339}, //100
    {9, "Chainsaw", 0, 341}, //500
    {10, "Dildo", 0, 321}, //20
    {11, "Dildo 2", 0, 322}, //20
    {12, "Vibrator", 0, 323}, //30
    {13, "Vibrator 2", 0, 324}, //30
    {14, "Flowers", 0, 325}, //10
    {15, "Cane", 0, 326}, //10
    {16, "Frag Grenade", 0, 342},
    {17, "Tear Gas Grenade", 0, 343}, //450
    {22, "M1911", 0, 346}, // 350
    {23, "M1911 (SILENCED)", 0, 347}, // 500
    {24, "Desert Eagle", 0, 348}, // 800
    {25, "Shotgun", 0, 349}, // 450
    {26, "Sawnoff Shotgun", 0, 350}, // 500
    {27, "Spas12", 0, 351},
    {28, "Micro Uzi", 0, 352}, // 650
    {29, "HK MP5", 0, 353}, // 900
    {30, "AK-47", 0, 355}, //1100
    {31, "M4A1", 0, 356},
    {32, "Tec-9", 0, 372}
}

I was wondering if I could possibly do the same in C# and if so how would it look?

This looks like it’d be an array or List of a class.

public class Item {
public int ItemID;
public string name;
public int Q;
public int ObjectID;

//constructor makes it convenient to create these:
public Item(int id, string n, int q, int oid) {
ItemID = id;
name = n;
Q = q;
ObjectID = oid;
}
}

//elsewhere
Item[] myArray = new Item[]{
new Item(0, "NULL", 0, 0),
new Item(1, "Brassknuckles", 0, 331),
//etc
};

But it’s more likely that you would be better off with a different data structure that actually takes advantage of Unity’s strengths - hard-coding lists like this is usually a pain to maintain, and the longer they get, the worse it is. Especially if each of these items has its own code.

For example, you might make each of these items a prefab, and if you need a list of all items, put them in the Resources folder and use Resources.LoadAll; you could also get a particular item by name using Resources.Load. If you have an Item script attached to each, you can get have all of this information accessible in your inspector view and easily editable. You could attach other components in addition to Item to give these prefabs the necessary functionality.