Friday, June 27, 2014

Instanse of Class

Hi,


When i need create new instanse from Interfaces? and Why?


For example:



interface ISampleInterface
{
void SampleMethod();
}
class ImplementationClass : ISampleInterface
{
// Explicit interface member implementation:
void ISampleInterface.SampleMethod()
{
// Method implementation.
}
static void Main()
{
// Declare an interface instance.
ISampleInterface obj = new ImplementationClass();
// Call the member.
obj.SampleMethod();
}
}


No comments:

Post a Comment