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

Gowtham RajamanickamPosted Apr 5, 2015, 11:24 PM
MahaPosted Mar 25, 2015, 11:08 PM
Pankaj Kumar ChoudharyPosted Mar 25, 2015, 10:17 PM
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
MahaPosted Mar 25, 2015, 9:40 PM
VulpesPosted Mar 25, 2015, 5:35 PM