Module Module1
Public Structure ListsEnd Module
'Holds a list of stringsEnd Structure
Dim ItemsList As System.Collections.Generic.List(Of String)
Public Sub Main()
'Create an reference to the Lists structureEnd Sub
Dim NewLists(1) As Lists
'Create two new instances to the List structure and two new
'instances of System.Collections.Generic Lists for the ItemsList
'member of Lists.
NewLists(0) = New Lists 'List of names
NewLists(1) = New Lists 'List of colors
NewLists(0).ItemsList = New System.Collections.Generic.List(Of String)
NewLists(1).ItemsList = New System.Collections.Generic.List(Of String)
'Assign the names to the first list. Assign the favorite colors of
'each person to the second.
NewLists(0).ItemsList.Add("Jim")
NewLists(1).ItemsList.Add("Blue")
NewLists(0).ItemsList.Add("Jack")
NewLists(1).ItemsList.Add("Black")
'Output what color each person likes.
Console.WriteLine(NewLists(0).ItemsList(0) & " likes " & NewLists(1).ItemsList(0))
Console.Write(NewLists(0).ItemsList(1) & " likes " & NewLists(1).ItemsList(1))
Console.Read() 'So I can see the output when debugging
using System;
using System.Collections.Generic;
namespace ConsoleApplication2
{
class Program}
{
public struct Lists}
{
//Holds a list of strings}
public List<String> ItemsList;
static void Main()
{
//Create two references to the Lists structure}
//Error: "; expected"
Lists[2] NewLists;
//Rest of program appears to have been written correctly?...
//Create two new instances to the List structure and two new
//instances of System.Collections.Generic Lists for the ItemsList
//member of Lists.
NewLists[0] = new Lists();
NewLists[1] = new Lists();
NewLists[0].ItemsList = new List<String>();
NewLists[1].ItemsList = new List<String>();
//Assign the names to the first list. Assign the favorite colors of
//each person to the second.
NewLists[0].ItemsList.Add("Jim");
NewLists[1].ItemsList.Add("Blue");
NewLists[0].ItemsList.Add("Jack");
NewLists[1].ItemsList.Add("Black");
//Output what color each person likes.
Console.WriteLine(NewLists[0].ItemsList[0] + " likes " + NewLists[1].ItemsList[0]);
Console.Write(NewLists[0].ItemsList[1] + " likes " + NewLists[1].ItemsList[1]);
Console.Read(); //So I can see the output when debugging