Posted by: Sourav | August 28, 2016

Passing a list and returning a list in VB,VB Teacher Sourav,Kolkata,09748184075

Option Strict On
Option Explicit On
Imports System
Imports System.Collections.Generic

Module Module1

Sub Main()
Dim intList As New List(Of Integer)
intList.AddRange({1, 2, 3, 4, 5})
Dim returnedList As New List(Of Integer)
returnedList = CType(calculator.add(intList), List(Of Integer))

For Each number As Integer In returnedList


End Sub

End Module
Public Class calculator
‘ Public Shared Function add(ByVal firstnumber As Integer, ByVal secondnumber As Integer) As Integer
‘ Return firstnumber + secondnumber

‘ End Function
Public Shared Function add(ByVal numbers As List(Of Integer)) As IList(Of Integer)
Dim sum As Integer = 0
For Each number As Integer In numbers
sum = sum + number
Console.WriteLine(“The sum of the numbers in the list are {0}”, sum)

Return numbers

End Function
End Class


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: