It is said that public modifier is used to access a class from outside.
public void IA1.Foo1() method is not accessible from the main method. But
void IA1.Foo1() method is accessible from the main method. Please tell me reason. Problem is highlighted.
using System;
interface IA1
{
void Foo1();
}
class CA : IA1
{
public void IA1.Foo1()
{
Console.WriteLine("In Foo2 of CA");
}
}
class Program
{
static void Main(string[] args)
{
IA1 a1; CA a;
a = new CA();
a1 = new CA();
a1.Foo1();
Console.ReadKey();
}
}
Loading

VulpesRank #55 · 29.2K reputationPosted Mar 25, 2015, 1:35 PM EDT
MahaRank #2,573 · 543 reputationPosted Mar 25, 2015, 5:40 PM EDT
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Mar 25, 2015, 6:17 PM EDT
A class that implements an interface can explicitly implement a member of that interface. When a member is explicitly implemented, it cannot be accessed through a class instance, but only through an instance of the interface. "
In Explicit Interface Implementation we can only access the method of explicit interface uing the instance of an interface.
we use the name 1A1.Foo1() for interface method
This name mechanism also known as fully qualified name.
because it provide a fully name of an method
MahaRank #2,573 · 543 reputationPosted Mar 25, 2015, 7:08 PM EDT
Gowtham RajamanickamRank #57 · 29K reputationPosted Apr 5, 2015, 7:24 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts