开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 2228|回复: 0

[求助] 大家帮忙看看这段代码

[复制链接]

0

精华

20

贡献

10

赞扬

帖子
14
软币
152
在线时间
9 小时
注册时间
2018-8-29
发表于 2018-9-21 16:42:30 | 显示全部楼层 |阅读模式
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才对啊,谁能带带小白,谢谢。

   




回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-4-20 21:09

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表