Get Value From Inventory List [C#]

Hey guys, so i’ve been hobby coding for a couple of years and i finally think its time for me to start convert some of my old projects into C# from different languages. The thing is that im having serious issues with lists / arrays / dictionaries / interfaces(?) etc etc.

This is the Item class of my game.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class Item : Game 
{
public string Name;
public string Description;

        public Item(string name, string description)
        {
            Name = name;
            Description = description;
        }
}

And this is the Main (Game) class of the game.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Game {
	
public class Game : MonoBehaviour {

	void Start () 
	{
		Setup();
	}	
	void Setup()
	{
			//Creates a list that will act like an inventory
			List<Item> playerItems = new List<Item>();

			//Create an item and give it a NAME + DESCRIPTION
			Item key = new Item("Key", "The key is old and heavy");
			
			//Add the item to the list playerItems
			playerItems.Add(key);

			//So this is my problem, how can i return whats in the list?
			Debug.Log(playerItems);  
                }
	}	
}

This is the output…

I want the output “Key, The key is old and heavy” (Name Description)

I’ve tried with for / blahblah / Contains / etc etc but no luck… This should be easy!!!
Try to be specific and tell me what I need to implement to get this thing working!

:smile:

you need to loop through your list using foreach loop for example

foreach( var itm in playerItems)
   Debug.Log(itm.Name + " : "+ itm.Description)

Bro, thats exactly what im talking about, your are the man, can’t thank you enough! I knew it would be easy!
Thanks a million!