Program in VB.net to find the presence of reverse of an element in a collection.

Rajnilari2015
Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 141
Suppose we have a colleciton as {78,92,44,63,71,97} and an element 29. We need to find if the reverse of 29 i.e. 92 is present in the collection. The below program will do so

Imports System.Collections.Generic
Imports System.Linq

Namespace ConsoleApplication2
Class Program
Private Shared Sub Main(args As String())

Dim intCollection = New List(Of Integer)() From { _
78, _
92, _
44, _
63, _
71, _
97 _
}
Dim element = 29
Dim reverseElement = Convert.ToInt32(String.Join("", element.ToString().Reverse()))
Console.Write(If(intCollection.IndexOf(reverseElement) <> -1, "Element found in the collection", "Element not found in the collection"))
Console.ReadKey()

End Sub
End Class
End Namespace

Result
-------
Element found in the collection

Comments or Responses

Login to post response