There is a Hashtable variable, the List <> is added to it. Why is it not output <> when outputting from Hashtable?
static void Main(string[] args) { Hashtable catalog = new Hashtable(); for (int i = 0; i < 5; i++)//просто создаётся лист с двумя структурами-мусик и добавляется в каталог-Хештейбл { List<Music> disk = new List<Music>() { new Music() { Author = $"a{i}", Song = $"asong{i}" }, new Music() { Author = $"b{i}", Song = $"bsong{i}" } }; //PrintDisk(disk); //тут не ругается и всё работает catalog.Add($"Disk{i}", disk); } //PrintDisk(catalog["Disk1"]);//ругается а на верху перед добавление нет Console.ReadKey(); } struct Music { public string Author; public string Song; } static void PrintDisk(List<Music> disk) { foreach (Music x in disk) { Console.WriteLine("Author: {0, 10}; Song: {1, 8}", x.Author, x.Song); } }
objectstored there. Therefore, it is advised to use a Dictionary, rather than a hash table. - Sergey