Should I use the ref or out keyword here?
- by Blankman
I have an object that may be null, which I will pass to a method that will set its properties.
So my code looks like:
User user = null; // may or may not be null at this point.
SetUserProperties(user);
UpdateUser(user);
public void SetUserProperties(User user)
{
if(user == null)
user = new User();
user.Firstname = "blah";
....
}
So I am updating the same object I pass into SetUserProperties.
Should I use the 'ref' keyword in my method SetUserProperties?