Function with pass by value Parameter : ByVal « Language Basics « VB.Net






Function with pass by value Parameter

Function with pass by value Parameter
Imports System

Public Class MainClass

  Shared Sub Main()
    Dim A() As String = {"HELLO", "GOODBYE"}
    Console.WriteLine("Original first item in array is: " _
      & A(0))
    Console.WriteLine("Original second item in array is: " _
      & A(1))
    AFunction(A)
    Console.WriteLine("After passing by value first item in array now is: " _
      & A(0))
    Console.WriteLine("After passing by value second item in array is: " _
      & A(1))
  End Sub

  Shared Sub AFunction(ByVal Foo As String())
    Foo(0) = "GOODBYE"
    Foo(1) = "HELLO"
  End Sub

End Class



           
       








Related examples in the same category

1.Object parameter passed by Value and by ReferenceObject parameter passed by Value and by Reference
2.Structure parameter passed by Value and by Reference
3.String parameter passed by Value and by ReferenceString parameter passed by Value and by Reference
4.Array parameter passed by Value and by ReferenceArray parameter passed by Value and by Reference
5.Passing arrays and individual array elements to proceduresPassing arrays and individual array elements to procedures
6.Modify Array Element By Value Modify Array Element By Value
7.Array passed By ValueArray passed By Value
8.Squares three values ByVal and ByRef, displays resultsSquares three values ByVal and ByRef, displays results