c# - passing properties of an object vs passing an object -


suppose have object looks this:

public class someobjectmodel {    long thelong {get; set;}    public string thestring {get; set;} } 

at point in code, pass of properties of object function:

public void somefunction(long longparameter, string stringparameter) { ... } 

what's difference, if any, between passing in parameters versus refactoring function take in someobjectmodel directly this:

public void somefunction(someobjectmodel theobject) {     long longparameter = theobject.thelong;     string stringparameter = theobject.thestring; } 

is there's difference between 2 approaches? there recommended approach?

thanks.

beside other differences in first approach if parameter values changed value in calling method remain same in second case change.

if pass object , later add new properties in object consuming call still able call method parameters have changed calling class well.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -