Reference Value Parameter VS Return value which one is good?
Posted
by CodeYun
on Stack Overflow
See other posts from Stack Overflow
or by CodeYun
Published on 2010-03-23T18:12:53Z
Indexed on
2010/03/23
18:13 UTC
Read the original article
Hit count: 253
c#
When we want to modify some value in one object we may use two different methods, just want to know which one is better or there is no big different between them.
void SomeMethod() { UserInfo newUser = New UserInfo(); ModifyUserInfo(newUser); //Modify UserInfo after calling void method GetUserInfo }
void ModifyUserInfo(UseerInfo userInfo) { userInfo.UserName = "User Name"; ..... }
void SomeMethod() { UserInfo newUser = New UserInfo(); //Assign new userinfo explicitly newUser = GetUserInfo(newUser);
}
UserInfo ModifyUserInfo(UseerInfo userInfo) { userInfo.UserName = "User Name"; ..... return userInfo; }
© Stack Overflow or respective owner