What is the right way to pass class parameters to a method
- by Schneider
Let's suppose I have three classes A, B and C
public class A
{
public int A1;
public string A2;
}
public class B
{
public char B1;
public double B2;
public decimal B3;
}
public class C
{
public string DoSomething(A a, B b)
{
var a1 = a.A1;
var b2 = b.B2;
var b3 = b.B3;
// DoSomething
return string.Empty;
}
}
If DoSomething() is using just some fields of the A and B classes, do you prefer to pass the whole object in parameters or create an intermediate class that has just the needed fields by the DoSomething method ?