**** Merged from MCS ****
[mono-project.git] / mcs / btests / FunctionArgu_ByReferenceD.vb
blobc0455cff3130aa932aa7fab1506ecd5c0d94a6d8
1 '==============================================================================================
2 'Name:Manish Kumar Sinha
3 'Email Address: manishkumarsinha@sify.com
4 'Test Case Name: Argument passing by Reference:
5 'APR-1.3.0: If the variable elements is of reference type i.e. it contain a pointers to a class
6 ' then procedure can change the members of instance to which it points
7 '==============================================================================================
9 Imports System
10 Imports System.Array
11 Module APR_1_3_0
13 Public Function Increase(ByRef A() As Long) As Long()
14 Dim J As Integer
15 For J = 0 To 3
16 A(J) = A(J) + 1
17 Next J
18 return A
19 End Function
20 ' ...
21 Public Function Replace(ByRef A() As Long) As Long()
22 Dim J As Integer
23 Dim K() As Long = {100, 200, 300,400}
24 A = K
25 For J = 0 To 3
26 A(J) = A(J) + 1
27 Next J
28 return A
29 End Function
30 ' ...
32 Sub Main()
33 Dim N() As Long = {10, 20, 30, 40}
34 Dim N1(3) As Long
35 Dim N2(3) As Long
36 Dim i As Integer
37 N1=Increase(N)
38 For i = 0 to 3
39 if (N(i) <> N1(i))
40 Throw New System.Exception("#A1, Unexception Behaviour in Increase Function")
41 end if
42 Next i
43 N2=Replace(N)
44 For i= 0 to 3
45 if ( N(i) <> N2(i))
46 Throw New System.Exception("#A2, Unexception Behaviour in Increase Function")
47 end if
48 Next i
50 End Sub
51 End Module
53 '==============================================================================================