i try to call base.Alan(); in HacimBul. But base. dont give intellisense alan method
public double HacimBul()
{
throw new Exception();
//return base..... --> how can i see base.Alan();
}
namespace interfaceClass
{
class Program
{
static void Main(string[] args)
{
}
}
interface Ikenar
{
double kenar { get; set; }
}
interface Iyukseklik
{
double yuksekli {get; set;}
}
interface IAlan
{
double Alan();
}
interface IHacim
{
double Hacim();
}
class Alan : Ikenar, IAlan
{
public double kenar
{
get;
set;
}
double IAlan.Alan()
{
return kenar * kenar;
}
}
class Hacim : Alan, Iyukseklik
{
public double kenar
{
get;
set;
}
public double yuksekli
{
get;
set;
}
public double HacimBul()
{
throw new Exception();
//return base..... --> how can i see base.Alan();
}
}
}
The method is not public or protected, it is private the way you’ve defined it, and even more private than just
privateas well, it is only available if you go through the interface.This means that in order to call the method you will have to:
Change the explicit implementation of your Alan method to an implicit one (making the method public) in Alan:
or, you will have to cast the instance during the call:
Unfortunately, with that last syntax there, you won’t actually be calling “base.Alan”, but rather just “this.Alan”, which might make a difference if you also override that method in the descendant class.
Here’s an example: