Lauren - 3 years ago 163
Vb.net Question

# How do I check if two string arrays are equal?

I'm trying to make a classification program for different animals. Below is my code (with only one animal as an example). The program is meant to take in user inputs of their answers to each question and then add them to an array (answerList). In this example, if

`answerList`
(the array containing all the user's inputs) is equal to the
`Horse`
array, the user will be told their animal is a horse.

However, the last
`four lines`
of code doesn't work. It produces no final output. Is there anyway to get my below code to work?

``````Sub Main()
Dim aAquatic, aInsect, aTentacles, aBird, aFlippers, aFly, aHoney, aLegs, aFeline, aStripes, aDomestic, aMilk, aWool, aSnout
Dim Horse = {“n”, “n”, “n”, “n”, “n,”, "n", “n”, “n”, “n”, “n”, “n”, “n”, “n”, “n”}
Dim animalArray = {Horse, Cow, Sheep, Pig, Dog, Cat, Lion, Tiger, Dolphin, Seal, Penguin, Ostrich, Sparrow, Bee, Wasp, Termite, Octopus}
Console.WriteLine("Welcome to the classification. Choose one of these animals and I will attempt to guess it: horse, cow, sheep, pig, dog, cat, lion, tiger, dolphin, seal, penguin, ostrich, sparrow, bee, wasp, termite, octopus. Click enter to continue.")
Console.WriteLine("Is your animal aquatic? (y or n)")
If aAquatic = "y" Then
ElseIf aAquatic = "n" Then
End If
Console.WriteLine("Is your animal an insect? (y or n)")
If aInsect = "y" Then
ElseIf aInsect = "n" Then
End If
Console.WriteLine("Does your animal have tentacles? (y or n)")
If aTentacles = "y" Then
ElseIf aTentacles = "n" Then
End If
Console.WriteLine("Is your animal a bird? (y or n)")
If aBird = "y" Then
ElseIf aBird = "n" Then
End If
Console.WriteLine("Does your animal have flippers? (y or n)")
If aFlippers = "y" Then
ElseIf aFlippers = "n" Then
End If
Console.WriteLine("Can your animal fly? (y or n)")
If aFly = "y" Then
ElseIf aFly = "n" Then
End If
Console.WriteLine("Can your animal make honey? (y or n)")
If aHoney = "y" Then
ElseIf aHoney = "n" Then
End If
Console.WriteLine("Does your animal have two legs? (y or n)")
If aLegs = "y" Then
ElseIf aLegs = "n" Then
End If
Console.WriteLine("Is your animal a feline? (y or n)")
If aFeline = "y" Then
ElseIf aFeline = "n" Then
End If
Console.WriteLine("Does your animal have stripes? (y or n)")
If aStripes = "y" Then
ElseIf aStripes = "n" Then
End If
Console.WriteLine("Is your animal a domestic pet? (y or n)")
End If
Console.WriteLine("Does your animal produce milk we can drink? (y or n)")
If aMilk = "y" Then
ElseIf aMilk = "n" Then
End If
Console.WriteLine("Does your animal have wool? (y or n)")
If aWool = "y" Then
ElseIf aWool = "n" Then
End If
Console.WriteLine("Does your animal have a snout? (y or n)")
If aSnout = "y" Then
ElseIf aSnout = "n" Then
End If

String.Join(", ", Horse)
End If
``````

Actually I´m not verry familiar with VB.Net, but shouldn´t it be:

``````dim s1 as String = String.Join(", ", answerList)
dim s2 as String = String.Join(", ", Horse)
If s1 = s2 Then
``````dim answerList as new List(Of String)