小编Gre*_*huk的帖子

为什么引用类型不会在C#中更新

这是我的c#代码.为什么引用类型不在C#中更新,下面是代码

 class Program
    {
        public static void Main(string[] args)
        {
            var a = A.field;
            A.field = "2";

            Console.WriteLine(a);
            Console.Read();
        }
    }
    public static class A
    {
        public static string field = "1";
    }
Run Code Online (Sandbox Code Playgroud)

结果是1,为什么?

c# static

2
推荐指数
1
解决办法
300
查看次数

标签 统计

c# ×1

static ×1