can't add to list

I’ve got a list that doesn’t seem to be working properly, and I can’t see what I’ve done.

When I try to add it doesn’t say e.g. (string, int ) as it should.


This is the script i’m using called myitems

using UnityEngine;
using System.Collections;

public class myitems {
	public string itemname;

	public int id;


The list does not reach the members, your list reference is just an address where all items are stored.

If you want to see/access members you need to first create the list, then create an item and add to the list.

Then you access the members via index.

List<myitems> list = new List<myitems>();  // Create list

void Start(){
   myitems item = new myitems();    // Create object
   list.Add(item);        // Add object to list
   list[0].itemname = "Name";  // Access via index