vb.net - List(of String()) contains String() -


i trying find out if array of strings exists in list of arrays of strings, running confusion. here code:

dim listresults list(of string) dim liststringarrays list(of string()) dim string() = {"foo", "bar", "stuff"} dim otherthing string() = {"foo", "bar", "stuff"}  liststringarrays.add(something)  if liststringarrays.contains(otherthing) listresults.add("true") else listresults.add("false") end if  if liststringarrays(0).equals(otherthing) listresults.add("true") else listresults.add("false") end if 

listresults contain 2 "false". strangely:

something(0) = otherthing(0) something(1) = otherthing(1) something(2) = otherthing(2) 

these evaluate true. how can find out if liststringarrays contains otherthing if contains not work?

bonus question: why contains not work in instance?

two arrays same contents still not same array. something = otherthing false. that's why contains doesn't work.

you instead use sequenceequal see whether of arrays in liststringarrays have same contents otherthing.

if liststringarrays.any(function(t) t.sequenceequal(otherthing)) 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -