A
Andreas Mueller
Hi,
I have a struct that implements an interface:
interface IMyInterface
{
void DoIt();
}
public struct MyStruct : IMyInterface
{
void IMyInterface.DoIt(){}
}
and somehwre else I have a method, that takes the interface :
public void UseIt(IMyInterface myi){}
As my implementation of the interface does not need any data, I decided
to make it a struct, as this should be more efficient.
But what is happening now when I pass a struct into the function that
takes the interface:
MyStruct s = new MyStruct();
UseIt(s);
Will the struct be "boxed" before it is passed or is there another
mechanism in place?
Thanks in advance,
Andy
I have a struct that implements an interface:
interface IMyInterface
{
void DoIt();
}
public struct MyStruct : IMyInterface
{
void IMyInterface.DoIt(){}
}
and somehwre else I have a method, that takes the interface :
public void UseIt(IMyInterface myi){}
As my implementation of the interface does not need any data, I decided
to make it a struct, as this should be more efficient.
But what is happening now when I pass a struct into the function that
takes the interface:
MyStruct s = new MyStruct();
UseIt(s);
Will the struct be "boxed" before it is passed or is there another
mechanism in place?
Thanks in advance,
Andy