大家帮忙看看这段代码
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Program
{
class a
{
public int val = 20;
}
class b
{
public static void c(a f1,int f2)
{
f1.val = f1.val + 5;
f2 = f2 + 5;
Console.WriteLine("f1.val:{0},f2:{1}", f1.val, f2);
}
}
class program
{
static void Main()
{
a a1 = new a();
int a2 = 10;
b.c(a1, a2);
Console.WriteLine("a1.val:{0},a2:{1}", a1.val, a2);
}
}
}
f1.val:25,f2:15
a1.val:25,a2:10
搞不懂,为什么a1.val会是25,a1做为a类的对象,应该是20才对啊,谁能带带小白,谢谢。
页:
[1]