zoukankan      html  css  js  c++  java
  • 一道面试题

    using System;
    public class Test1
    {
    public static void Main()
    {
    int num = 0;
    Person p = new Person("Li");
    A1(p, num);
    Console.WriteLine("{0},{1}", p.name, num);
    }
    static void A1(Person p, int num)
    {
    p = new Person("Wang");
    num = 1;
    }
    }
    public class Person
    {
    public string name;
    public Person(string name)
    {
    this.name = name;
    }
    }

    -------------------------------------------------------


    using System;
    public class Test1
    {
    public static void Main()
    {
    int num = 0;
    Person p = new Person("Li");
    A1(p, num);
    Console.WriteLine("{0},{1}", p.name, num);
    }
    static void A1(Person p, int num)
    {
    p.name = "Wang";
    num = 1;
    }
    }
    public class Person
    {
    public string name;
    public Person(string name)
    {
    this.name = name;
    }
    }

     两道题目的结果不同,求解释...

  • 相关阅读:
    idea中maven自动导入出现问题
    DDIA
    DDIA
    DDIA
    DDIA
    DDIA
    DDIA
    DDIA
    MIT 6.824 第五次作业Primary-Backup Replication
    MIT 6.824 第四次作业GFS
  • 原文地址:https://www.cnblogs.com/fengye87626/p/2841595.html
Copyright © 2011-2022 走看看