Query in C# Interface concept
Hi Team,I am learning programming skills and executing the following code
interface first
{
void displayfirst();
}
interface second
{
void displaysecond();
}
class intimplement : first, second
{
public void displayfirst()
{
Console.WriteLine("I am first interface");
}
public void displaysecond()
{
Console.WriteLine("I am second interface");
}
}
class program
{
static void Main(string[] args)
{
intimplement assign = new intimplement();
first avalue = (first)assign;
avalue.displayfirst();
second bvalue = (second)assign;
bvalue.displaysecond();
}
}
when I execute the above code I am getting the expected result as
I am first interface
I am second interface
However, if I remove public modifier from the class intimplement then I am getting following message
intimplement.displaysecond()' cannot implement an interface member because it is not public.
intimplement.displayfirst()' cannot implement an interface member because it is not public.
By default interface members are public so why should I declare the method as Public while implementing interface.
Please clarify. Thank you very much.