If you want this to work, you need to pass by reference:
public static void InitializeObjectA(ref ObjectA device)
{
Or:
public static void InitializeObjectA(out ObjectA device)
{
Without that, InitializeObjectA
sets the device
parameter to a new ObjectA()
, but that will not affect the caller, because, by default, references are passed by value.
Note that, if you're just trying to initialize, returning an instance instead of void is often a better way to handle this:
public static ObjectA InitializeObjectA()
{
return new ObjectA();
}
This avoids the need to use ref
or out
passing.