Help with Instantiated Game Objects?

I’m new to unity and C# so I need some help. I’m making a simple card game. I’ve created a CARD class and a CardDatabase. I then created a PlayerDeck class that loads, shuffles and deal the cards. Here’s my PlayerDeck Class code:

public class PlayerDeck : MonoBehaviour
{
public List deck = new List();
public List container = new List();
public int x;
public int deckindex;
public GameObject cardobject, cardPrefab;
public GameObject panel;
void Start()
{
LoadCards();
Shuffle();
DealCards();
}
public void LoadCards()
{
x = 0;
for (int i = 0; i < 64; i++)
{
x = i;
deck = CardDatabase.cardList[×];
}
}
public void Shuffle()
{
for (int j = 0; j < 5; j++)
{
for (int i = 0; i < 64; i++)
{
container[0] = deck*;*
int rnd = Random.Range(i, 64);
deck = deck[rnd];
deck[rnd] = container[0];
}
}

}
public void DealCards()
{

cardobject = (GameObject) Instantiate(cardPrefab);
cardobject.transform.SetParent(panel.transform, false);
cardobject.GetComponent().sprite = deck[deckindex].thisImage;
}

// Update is called once per frame
void Update()
{

}
}
Everything is fine. The correct image loads on the gameobject. However I don’t know how to transfer the other crucial info using the GetComponent method for things like the CardID, card description, etc…
When I run this code, the PlayerDeck gameobject in the Hierarchy gets populated with the cards from the database (hence, the loading stage). The “deck” list has 64 elements. The elements are shuffled. Each element in the List has a name, id, description, value, image, and ability number. These are the pieces of info I need to access when I instantiate the cardprefab. Any help would be appreciated

int playerDeckIndex = gameObject.GetComponent<PlayerDeck>().deckindex

How does this relate to the cardobject Game Object? I’m confused. Can you explain please?

You would use GetComponent on the GameObject that has your class attached, your class being the component, allowing you access to all its public variables.

I understand what you’re saying, but I’m still confused how to write for a specific attribute. Your example is a whole new variable. What do I do with that? How does that retrieve let’s say the Card ID from the deck element and attach it to the instantiated prefab? Any clarification would help. If you know how, could you write the code to my code so I can see?

My example is just if you were in a different class and wanted to pull that variable’s value to it. Let’s say you wanted to change deckindex in that object’s PlayerDeck class from a different class.

gameObject.GetComponent<PlayerDeck>().deckindex = 1;