Method calls within same class w/Interface
In the following code snippet, the ITest interface function "Paint()" is being implemented in the TestPaint class. I'm trying to see if I can call the class's implementation of Paint() from another function without creating an instance of ITest.
Is this possible?
namespace WindowsApplication1
{
interface ITest
{
void Paint();
}
public class TestPaint : ITest
{
void ITest.Paint()
{
System.Windows.Forms.MessageBox("Paint called");
}
public void TestPaint()
{
ITest interfaceOfTest; //Don't want to have to
interfaceOfTest = (ITest)this; //do all this just to
interfaceOfTest.Paint(); //call TestPaint.Paint()
}
}
}
^-^_^-^_^-^_^-^_^-^_^
Gabriel Montanaro
^-^_^-^_^-^_^-^_^-^_^
|