Pass by reference: Which is more readable/right?

I have the following class:

public class Person
{
     public String Name { get; set; }
}

I have a method that takes in Person and a String as parameters:

public void ChangeName(Person p, String name)
{
     p.Name = name;
}

Since Person was passed by reference, it should change the Name of the passed instance.

But is this method more readable than the one above?

public Person ChangeName(Person p, String name)
{
     p.Name = name;
     return p;
}
9
задан Ian 11 March 2011 в 06:02
поделиться