关于 byval 和 byref 的 问题
程序代码:
Sub addref(ByRef one As Integer, Optional ByVal two As Integer = 18) one = one + two System.Console.WriteLine("one+two={0}", one) End Sub Sub Main() Dim a As Integer Dim b As Integer a = 10 b = 20 System.Console.WriteLine("调用add前,a={0}", a) addref(a, b) System.Console.WriteLine("调用add后,a={0},b={0}", a, b) System.Console.ReadLine() End Sub为什么a和 b 都被 改变了呢,
Sub addref(ByRef one As Integer, Optional ByVal two As Integer = 18) two 已经 被我 用 byval 声明了,这是 为什么