Is it acceptable practice to pass an object to a method and then return the same object, rather than create a new object inside the method itself?
As an example: if there is an entity class as follows:
class UserDetails {
int UserID { get; set; }
string UserName { get; set; }
string UserAge { get; set; }
}
And then I pass an instance of this class to the method as follows:
UserDetails UserInfo = new UserDetails();
UserInfo = Get_Details(UserInfo);
Can the method be used as follows?
public UserDetails Get_Details(UserDetails user) {
user.age = 32;
return user;
}
source
share