다음은 내가 수행중인 작업의 빠른 예입니다. 기본적으로 하나의 클래스 또는 별도의 클래스로 구현할 수있는 여러 인터페이스가 있으므로 각 응용 프로그램을 응용 프로그램에 저장합니다. 내 유일한 질문은 변수 myInterface, yourInterface 및 ourInterface에 관한 것입니다. 그들은 동일한 객체를 참조합니까? 아니면 3 개의 다른 객체가 있습니까?.Net에서 다중 인터페이스 및 객체 인스턴스 구현
interface IMyInterface
{
void MyFunction();
}
interface IYourInterface()
{
void YourFunction();
}
interface IOurInterface()
{
void OurFunction();
}
public class MainImplementation : IMyInterface, IYourInterface, IOurInterface
{
public void MyFunction() { }
public void YourFunction() { }
public void OurFunction() { }
}
private IMyInterface myInterface;
private IYourInterface yourInterface;
private IOurInterface ourInterface;
static void Main(string[] args)
{
myInterface = new MainImplementation() as IMyInterface;
yourInterface = myInterface as IYourInterface;
ourInterface = myInterface as IOurInterface;
}
보너스 : 더 좋은 방법이 있습니까?
저는이 질문의 제목에 약간 혼란 스럽습니다. ByVal 또는 ByRef는 제공된 코드 샘플과 어떤 관련이 있습니까? 모든 메소드는 매개 변수를 사용하지 않습니다. – JohnFx
해결되었습니다. 바라기를, 그것은 조금 더 낫다. 긴 날이었습니다 :) – kevindaub