unity csharp struct

Code Example - unity csharp struct

                
                        struct InventorySlot {
    //Variable declaration
    //Note: I'm explicitly declaring them as public, but they are public by default. You can use private if you choose.
    public bool IsFree;
    public string Name;
   
    //Constructor (not necessary, but helpful)
    public InventorySlot(bool isFree, string name) {
        this.IsFree = isFree;
        this.Name = name;
    }
}
//With this code, you can create a new inventory slot by simply calling the constructor:

InventorySlot slot1 = new InventorySlot(false, "Slot 1");