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