As shown in below code, I have created Sample class which implements the IPrint interface's Print method and it also has additional SampleTest method. In main section I create object of Sample class and assign it to interface. However what if I want to access SampleTest method.
Also what are the thoughts on this code? Is it ok to implement SampleTest additional method and call it from main?
interface IPrint
{
void Print();
}
class Sample : IPrint
{
public void Print()
{
Console.WriteLine("Print...");
}
public void SampleTest()
{
Console.WriteLine("SampleTest...");
}
}
class Program
{
static void Main(string[] args)
{
IPrint print = new Sample();
print.Print();
// How would I access SampleTest methos of Sample class here
}
}